Created
March 5, 2016 14:29
-
-
Save ninjapanzer/40ffafdc119dbed1dda7 to your computer and use it in GitHub Desktop.
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
| #include <iostream> | |
| int main(int argc, char* argv[]) { | |
| const int SIZE = 12; | |
| std::string* months = new std::string[SIZE]; | |
| int* max_days = new int[SIZE]; | |
| months[0] = "january"; | |
| max_days[0] = 31; | |
| months[1] = "february"; | |
| max_days[1] = 29; | |
| months[2] = "march"; | |
| max_days[2] = 31; | |
| months[3] = "april"; | |
| max_days[3] = 30; | |
| months[4] = "may"; | |
| max_days[4] = 31; | |
| std::string user_selection = static_cast<std::string>(argv[1]); | |
| // Loopup index of month | |
| int selected_month_index = -1; | |
| for(int i = 0; i < SIZE; i++){ | |
| if(months[i] == user_selection){ | |
| selected_month_index = i; | |
| } | |
| } | |
| if(selected_month_index > -1){ | |
| std::cout << "The number of days in " << user_selection << " is " << max_days[selected_month_index] << std::endl; | |
| }else{ | |
| std::cout << "Incorrect Selection" << std::endl; | |
| } | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment