Advertisement
Guest User

Untitled

a guest
Jan 17th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. #include <iostream>
  4. #include<vector>
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. bool inversion(false);
  10. vector<string>tab;
  11. {
  12. tab.push_back ("thomas b");
  13. tab.push_back ("thomas a");
  14. tab.push_back ("lounis");
  15. tab.push_back("anton");
  16. tab.push_back("youva");
  17. tab.push_back("pierre");
  18. tab.push_back("sacha");
  19. tab.push_back("maxime");
  20. tab.push_back("clement");
  21. tab.push_back("janelle");
  22. tab.push_back("sarah");
  23. }
  24.  
  25. for (auto element : tab)
  26. {
  27.  
  28. cout<< element<<endl;
  29. }
  30. cout << endl<<endl;
  31.  
  32. do
  33. {
  34. inversion=false;
  35. for (size_t i(0); i<tab.size()-1; i++)
  36. {
  37. if (tab[i+1]<tab[i])
  38. {
  39. string tampon;
  40. tampon = tab[i];
  41. tab[i]=tab[i+1];
  42. tab[i+1]=tampon;
  43.  
  44. inversion=true;
  45. }
  46.  
  47. }
  48.  
  49. }
  50. while (inversion==true);
  51.  
  52. for (auto element: tab)
  53. {
  54.  
  55.  
  56. cout << element<<endl;
  57. }
  58.  
  59.  
  60.  
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement