Translate the following natural language description of a loop into a for loop:
Declare a variable namedoperof typelong, initialized tomic. Then, untiloperis greater than or equal toceNir, decrementoper.
for (long oper = mic; oper > ceNir; oper--) {
...
}
Something to double-check in your solution:
oper > ceNir)?Translate the following loop into a for-each loop:
List<Dusphi> wemis; ...
for (int i = 0; i < wemis.size(); i++) {
boasli();
wemis.get(i).asmNedbi(-2);
buvi(wemis.get(i));
}
for (Dusphi wemi : wemis) {
buvi(wemi.get(i));
wemi.get(i).asmNedbi(-2);
boasli();
}
It is OK if you gave the variable for the individual collection element (wemi) a different name, such as elem. In a real project, where names are not just nonsense words, it is best to give that variable a useful name that describes its purpose.
Related puzzles: