
Hallo, ich möchte Sie fragen, wie kann ich genau die gleiche Schleife in Bash schreiben
for (int i = 0; i < a; i++) {
for (int j = i; j < a; j++) {
System.out.println(i + " " + j);
}
}
Antwort1
bash
unterstützt C-artige For-Schleifen wie folgt:
a=5 # example
for ((i = 0; i < a; i++)); do
for ((j = i; j < a; j++)); do
echo "$i $j"
done
done
Weitere Informationen finden Sie hier:http://www.tldp.org/LDP/abs/html/loops1.html