Skip to content

Instantly share code, notes, and snippets.

@webmstk
Last active December 15, 2022 20:06
Show Gist options
  • Save webmstk/b3aa2fea4486d118a85f14c40884c7de to your computer and use it in GitHub Desktop.
Save webmstk/b3aa2fea4486d118a85f14c40884c7de to your computer and use it in GitHub Desktop.
import 'dart:io';
void main() {
// 1.
int monthCount = 3;
switch (monthCount) {
case 1:
print('Январь');
break;
case 2:
print('Февраль');
break;
case 3:
print('Март');
break;
case 4:
print('Апрель');
break;
case 5:
print('Май');
break;
case 6:
print('Июнь');
break;
case 7:
print('Июль');
break;
case 8:
print('Август');
break;
case 9:
print('Сентябрь');
break;
case 10:
print('Октябрь');
break;
case 11:
print('Ноябрь');
break;
case 12:
print('Декабрь');
break;
default:
print('Зомбябрь');
}
// 2.
for (var i = 0; i <= 100; i++) {
if (i.isOdd) {
continue;
}
print(i);
}
// 3.
print('Введите число:');
String? input = '';
int sum = 0;
do {
input = stdin.readLineSync();
int? number = int.tryParse(input ?? '');
if (number == null) {
print('Это не число, попробуйте ещё раз:');
continue;
}
sum += number;
print('Сумма всех введённых вами чисел - $sum');
print('Введите следующее число или "stop", если надоело:');
} while (input != 'stop');
print('Спасибо, вряд ли вы запустите меня снова :(');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment