#!bash
ARRAY=(one two three four five)
가능한 모든 조합을 반복없이 나열하고 배열이 순서대로 정렬되지 않으며 출력이 순서대로 정렬 될 필요가 없습니다.Bash는 배열의 모든 값을 비교합니다.
원하는 출력
one two
one three
one four
one five
two three
two four
two five
three four
three five
four five
#!bash
ARRAY=(one two three four five)
가능한 모든 조합을 반복없이 나열하고 배열이 순서대로 정렬되지 않으며 출력이 순서대로 정렬 될 필요가 없습니다.Bash는 배열의 모든 값을 비교합니다.
원하는 출력
one two
one three
one four
one five
two three
two four
two five
three four
three five
four five
for
루핑 떠들썩한 파티와 :
arr=(two four one three five)
len=${#arr[*]}
for ((i=0; i < $len; i++)); do
for ((j=$((i+1)); j < $len; j++)); do
echo "${arr[$i]} ${arr[*]:$j:1}"
done
done
출력은 :
two four
two one
two three
two five
four one
four three
four five
one three
one five
three five
고맙습니다. – nyitguy
@nyitguy, 오신 것을 환영합니다. – RomanPerekhrest
이 같은데 숙제. 너 뭐 해봤 니? 작동하지 않습니까? – donjuedo