Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void sort(int *p, int nSize);
- int nCounter = 0;
- ////////////////////////////////////////////////////
- int main() //
- {
- int nArr[15] = {48, 18, -7, 97, -11, 88,-2,13,5,22, 4, 111, 33, 2, 92};
- sort(&nArr[0], 15);
- for(int i = 0; i < 15; i++) cout << nArr[i] << ", ";
- cout << endl;
- cout << "nCounter = " << nCounter << endl;
- }
- ////////////////////////////////////////////////////
- void sort(int *p, int nSize) //
- {
- int i = 0,
- u = 0,
- nF = 0;
- L_01:
- for(; i < nSize-1; i++)
- {
- if( p[i] > p[i+1] )
- {
- u = p[i];
- p[i] = p[i+1];
- p[i+1] = u;
- nF = 1;
- nCounter = nCounter + 1;
- }
- }
- if(nF == 1)
- {
- nF = 0;
- i = 0;
- goto L_01;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement