fabbe680

Alpha Order v1.1

Nov 29th, 2018
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <algorithm>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. string name1, name2, name3;
  10. string no1, no2, no3, store;
  11.  
  12. cout << "*** Enter three full names, including first and last. ***" << endl;
  13.  
  14. getline(cin, name1);
  15. getline(cin, name2);
  16. getline(cin, name3);
  17.  
  18. //Transform to lower case
  19.  
  20. std::transform(name1.begin(), name1.end(), name1.begin(), ::tolower);
  21. std::transform(name2.begin(), name2.end(), name2.begin(), ::tolower);
  22. std::transform(name3.begin(), name3.end(), name3.begin(), ::tolower);
  23.  
  24. no1 = name1;
  25. no2 = name2;
  26. no3 = name3;
  27.  
  28. //Order names
  29.  
  30. if (no1 > no2) {
  31. store = no1;
  32. no1 = no2;
  33. no2 = store;
  34. }
  35.  
  36. if (no1 > no3) {
  37. store = no1;
  38. no1 = no3;
  39. no3 = store;
  40. }
  41.  
  42. if (no2 > no3) {
  43. store = no2;
  44. no2 = no3;
  45. no3 = store;
  46. }
  47.  
  48. //Print
  49.  
  50. cout << "----" << endl;
  51. cout << "No.1: " << no1 << endl;
  52. cout << "No.2: " << no2 << endl;
  53. cout << "No.3: " << no3 << endl;
  54.  
  55. return 0;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment