Advertisement
fabbe680

3.2

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