Created
November 25, 2020 13:04
-
-
Save karabanovbs/58ad862fa2c040f92e73d00a83b7d552 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 2.4 Управляющие конструкции | |
// Используя циклы, напишите программу, которая выводит на консоль все четные числа от 0 до 100. | |
void main() { | |
// Прохидим все, выводим только четные | |
for (var i = 0; i < 100; i++) { | |
if (i.isEven) { | |
print(i); | |
} | |
} | |
for (var i in Iterable<int>.generate(100, (i) => i)) { | |
if (i.isEven) { | |
print(i); | |
} | |
} | |
int i = 0; | |
while (i < 100) { | |
if (i.isEven) { | |
print(i); | |
} | |
i++; | |
} | |
// Идем только по четным | |
for (var i = 0; i < 100; i+=2) { | |
print(i); | |
} | |
for (var i in Iterable<int>.generate(50, (i) => (i*2))) { | |
print(i); | |
} | |
i = 0; | |
while (i < 100) { | |
print(i); | |
i+=2; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment