Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "pch.h"
- #include <iostream>
- #include <chrono>
- #include <thread>
- using namespace std;
- int main()
- {
- const int numElements = 10;
- int a[numElements] = { 0,12,48,3,0,5,2,7,58,0 };
- int i = 0, temporarry = 0, index_temporarry = 0;
- for (int i = 0; i < numElements; i++)
- {
- while ((i != 0) && (a[i] == 0) && (a[i] < a[i - 1]))
- {
- int temporarry = a[i];
- int index_temporarry = i;
- a[i] = a[i - 1];
- a[i - 1] = temporarry;
- //cout << "a [ " << i << " ] = " << a[i] << "\ta [ " << i - 1 << " ] " << a[i - 1] << "\n";
- i--;
- }
- cout << "a [ " << i << " ] = " << a[i] << "\n";
- }
- cout << "\n\n";
- for (int i = 0; i < numElements; i++)
- {
- cout << "a [ " << i << " ] = " << a[i] << "\n";
- }
- cout << "\n";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment