Last active
August 2, 2020 08:25
-
-
Save Medvedoc/f4d1732b0a1084f10ce05216e41334b2 to your computer and use it in GitHub Desktop.
My_tasks_Dart
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
void main() { | |
/* | |
Задача 3 | |
Вам будет дан год, верните тот век, в котором он находится. Первый век охватывает период с 1 года до 100 года включительно, второй - с 101 года до 200 года включительно и т. д. | |
Входные данные:1705,1900,1601,2000 | |
Выходные данные:18,19,17,20 | |
*/ | |
var years = [1705, 1900, 1601, 2000]; | |
for (int i = 0; i < years.length; i++) { | |
if (years[i] % 100 == 0) { | |
print(years[i] ~/ 100); | |
} else { | |
print(years[i] ~/ 100+1); | |
} | |
} | |
} | |
//Подсказки | |
// % - Получить остаток от целочисленного деления | |
// ~/ - Деление, возвращая целочисленный результат |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment