Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Laboration 3, Assignment_2.cpp
- // Fabian Tjernström (fatj1700) 2018-12-02
- #include <iostream>
- #include <string>
- #include <algorithm>
- using namespace std;
- int main()
- {
- string name1, name2, name3;
- string no1, no2, no3, store;
- cout << "*** Enter three full names, including first and last. ***" << endl;
- getline(cin, name1);
- getline(cin, name2);
- getline(cin, name3);
- //Transform to lower case
- std::transform(name1.begin(), name1.end(), name1.begin(), ::tolower);
- std::transform(name2.begin(), name2.end(), name2.begin(), ::tolower);
- std::transform(name3.begin(), name3.end(), name3.begin(), ::tolower);
- no1 = name1;
- no2 = name2;
- no3 = name3;
- //Order names
- if (no1 > no2) {
- store = no1;
- no1 = no2;
- no2 = store;
- }
- if (no1 > no3) {
- store = no1;
- no1 = no3;
- no3 = store;
- }
- if (no2 > no3) {
- store = no2;
- no2 = no3;
- no3 = store;
- }
- //Print
- cout << "----" << endl;
- cout << "No.1: " << no1 << endl;
- cout << "No.2: " << no2 << endl;
- cout << "No.3: " << no3 << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement