Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- //////////////////////////////////////////////////////
- void swap(int &n1, int &n2)
- {
- int n3 = n1;
- n1 = n2;
- n2 = n3;
- }
- //////////////////////////////////////////////////////
- void sort(int *p, int n) //
- {
- int nF;
- L_01: nF = 0;
- for(int i = 0; i < n-1; i++)
- {
- if( p[i] > p[i+1] ) { nF = 1; swap( p[i], p[i+1] ); }
- }
- if(nF) goto L_01;
- }
- ////////////////////////////////////////////////////////
- void print(int *p, int n)
- {
- for(int i = 0; i < n; i++)
- {
- printf("%d, ", p[i]);
- }
- }
- ///////////////////////////////////////////////////////
- int main()
- {
- int mas[99] = {5, 11, 2, 6, 34, 1, 7};
- sort(mas, 7);
- print(mas, 7);
- // system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement