Created
November 19, 2020 10:44
-
-
Save internetova/9fc2322ca4f4814ebe29b49d5917e8d7 to your computer and use it in GitHub Desktop.
This file contains 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
// Задание 1 | |
// Используя switch, напишите программу в методе main(), которая выводит название месяца по номеру от 1 до 12. | |
void main() { | |
const months = <int, String>{ | |
1: 'Январь', | |
2: 'Февраль', | |
3: 'Март', | |
4: 'Апрель', | |
5: 'Май', | |
6: 'Июнь', | |
7: 'Июль', | |
8: 'Август', | |
9: 'Сентябрь', | |
10: 'Октябрь', | |
11: 'Ноябрь', | |
12: 'Декабрь' | |
}; | |
var monthNumber = 11; | |
switch(monthNumber) { | |
case 1: | |
case 2: | |
case 3: | |
case 4: | |
case 5: | |
case 6: | |
case 7: | |
case 8: | |
case 9: | |
case 10: | |
case 11: | |
case 12: | |
print(months[monthNumber]); | |
break; | |
default: | |
print("Неверный номер месяца"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
о, крутая реализация)