Created
May 1, 2021 18:44
-
-
Save abhijangda/baa984ac964dd55f9b4cb69938a78df9 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> | |
| #include <vector> | |
| #include <string> | |
| enum AMorPM { | |
| AM, | |
| PM | |
| }; | |
| struct Time { | |
| int hour; | |
| int minute; | |
| AMorPM amOrPM; | |
| Time() {} | |
| Time(std::string& strRepr) { | |
| hour = std::stoi(strRepr.substr(0, 2)); | |
| minute = std::stoi(strRepr.substr(3, 2)); | |
| amOrPM = (std::stoi(strRepr.substr(5, 2)) == "AM") ? AMorPM::AM : AMorPM::PM; | |
| } | |
| }; | |
| struct Event { | |
| Time startTime; | |
| Time endTime; | |
| Event(std::string& strRepr) { | |
| startTime = Time(strRepr); | |
| endTime = Time(strRepr.substr(strRepr.find("-"))); | |
| } | |
| }; | |
| void convertStrArrayToEventArray(std::vector<Event>& eventArray, std::string* strArray, int numEvents) { | |
| for (int i = 0; i < numEvents; i++) { | |
| std::string& strEvent = strArray[i]; | |
| Event event(strEvent); | |
| eventArray.push_back(event); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment