Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- ///////////////////////////////////////////
- enum class month : int //
- {
- January = 1,
- February,
- March,
- April,
- May,
- June,
- July,
- August,
- September,
- October,
- November,
- December
- };
- ////////////////////////////////////////////////////////
- string get_month(month m) //
- {
- switch(m)
- {
- case month:: January: return "Январь";
- case month:: February: return "Февраль";
- case month:: March: return "Март";
- case month:: April: return "Апрель";
- case month:: May: return "Май";
- case month:: June: return "Июнь";
- case month:: July: return "Июль";
- case month:: August: return "Август";
- case month:: September: return "Сентябрь";
- case month:: October: return "Октябрь";
- case month:: November: return "Ноябрь";
- case month:: December: return "Декабрь";
- }
- }
- ////////////////////////////////////////////////////////
- int main() //
- {
- setlocale(LC_ALL, "rus");
- int nNum;
- month monthNum;
- string monthName;
- while(true)
- {
- cout << "Введите номер месяца: ";
- cin >> nNum;
- monthNum = static_cast<month>(nNum);
- if(monthNum > month::December)
- {
- cout << "Неправильный номер!" << endl;
- }
- if(monthNum < month::January)
- {
- cout << "До свидания!" << endl;
- break;
- }
- monthName = get_month(monthNum);
- cout << " = " << monthName << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement