Created
March 22, 2021 19:58
-
-
Save mikaelo/81aaa0e4792e08cb6fe51e42b9d243e2 to your computer and use it in GitHub Desktop.
Flutter_Surf_2_5
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
/* | |
* Используя switch, напишите программу в методе main(), которая выводит название месяца по номеру от 1 до 12. | |
*/ | |
var monthMap = <int, String> { | |
1: "Январь", | |
2: "Февраль", | |
3: "Март", | |
4: "Апрель", | |
5: "Май", | |
6: "Июнь", | |
7: "Июль", | |
8: "Август", | |
9: "Сентябрь", | |
10: "Октябрь", | |
11: "Ноябрь", | |
12: "Декабрь" | |
}; | |
void main() { | |
var month = 1; | |
switch(month) { | |
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 ("${monthMap[month]}"); | |
break; | |
default: | |
print ("Такого месяца не существует"); | |
break; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Интересное решение, но зачем тогда switch?)