Guest User

bubble

a guest
Oct 12th, 2018
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1.  
  2.  
  3. #include <iostream>
  4. #include <stdlib.h>
  5. #include <stdio.h>
  6. #include <string>
  7. #include <conio.h>
  8. #include <string.h>
  9. #include <iomanip>
  10. #include <array>
  11. #include <windows.h>
  12. #include <cstdlib>
  13. #include <ctime>
  14. #include <string>
  15.  
  16.  
  17. using namespace std;
  18.  
  19.  
  20.  
  21. int main() // main function
  22. {//function start
  23.  
  24. int yeet[5] = {100,22,101,12,7};
  25. bool done = false;
  26.  
  27. int length = 0;
  28. int stop = sizeof(yeet);
  29.  
  30. for (int x = 0; x < 5; x++)
  31. {
  32. cout << yeet[x] << ' ';
  33. }
  34. system("PAUSE");
  35. system("cls");
  36.  
  37. while(done != true)
  38. {
  39. for (int i = 0; i < 4; i++)
  40. {
  41. if (yeet[i] > yeet[i + 1])//putting string in order
  42. {
  43. swap(yeet[i], yeet[i + 1]);
  44. }
  45.  
  46. for (int x = 0; x < sizeof(yeet) / sizeof(yeet[0]); x++)//checking if string is in order (low to high)
  47. {
  48. if (yeet[x] < yeet[x+1])
  49. {
  50. length++;
  51. if (length == stop )
  52. {
  53. done = true;
  54. }
  55.  
  56. }
  57. }
  58.  
  59.  
  60. for (int x = 0; x < 5; x++)
  61. {
  62. cout << yeet[x] << ' ';
  63. }
  64.  
  65. Sleep(100);
  66. system("cls");
  67. }
  68.  
  69. }
  70.  
  71. cout << "Sorting is complete, press any key to see finished array.\n";
  72. system("PAUSE");
  73. system("cls");
  74.  
  75.  
  76. for (int x = 0; x < 5; x++)
  77. {
  78. cout << yeet[x] << ' ';
  79. }
  80.  
  81. cout << endl; //formatting
  82.  
  83. system("PAUSE");
  84. return 0;
  85. }
Advertisement
Add Comment
Please, Sign In to add comment