avr39-ripe

Untitled

Mar 5th, 2019
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. #include "pch.h"
  2. #include <iostream>
  3. #include <chrono>
  4. #include <thread>
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10. const int numElements = 10;
  11. int a[numElements] = { 0,12,48,3,0,5,2,7,58,0 };
  12. int i = 0, temporarry = 0, index_temporarry = 0;
  13.  
  14.  
  15. for (int i = 0; i < numElements; i++)
  16. {
  17. while ((i != 0) && (a[i] == 0) && (a[i] < a[i - 1]))
  18. {
  19. int temporarry = a[i];
  20. int index_temporarry = i;
  21. a[i] = a[i - 1];
  22. a[i - 1] = temporarry;
  23. //cout << "a [ " << i << " ] = " << a[i] << "\ta [ " << i - 1 << " ] " << a[i - 1] << "\n";
  24. i--;
  25. }
  26.  
  27. cout << "a [ " << i << " ] = " << a[i] << "\n";
  28. }
  29. cout << "\n\n";
  30. for (int i = 0; i < numElements; i++)
  31. {
  32. cout << "a [ " << i << " ] = " << a[i] << "\n";
  33. }
  34.  
  35. cout << "\n";
  36. return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment