Advertisement
elephantsarecool

map1

May 28th, 2018
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.53 KB | None | 0 0
  1. #include<iostream>
  2. #include<map>
  3. #include<string>
  4. using namespace std;
  5. int main()
  6. {
  7.   string s;
  8.   map <string,int> month =
  9.   {
  10.     {"January",31},
  11.     {"February",28},
  12.     {"March",31},
  13.     {"April",30},
  14.     {"May",31},
  15.     {"June",30},
  16.     {"July",31},
  17.     {"August",31},
  18.     {"September",30},
  19.     {"October",31},
  20.     {"November",30},
  21.     {"December",31}
  22.   };
  23.   while(1)
  24.   {
  25.     cin>>s;
  26.     if(s=="exit")break;
  27.     if(month[s]) cout<<month[s]<<endl;
  28.     else cout<<"unknown month"<<endl;
  29.   }
  30.   return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement