Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int nNumb[20] = { 7, 3, 101, 44, 6, 8, 102, 111, 32, 18,
- 23, 2, 3, 4, 5, 7, 101, 0, 22, 23};
- void foo (int *p);
- void sort(int *p);
- ////////////////////////////////////////////////////
- int main() //
- {
- foo (nNumb);
- sort(nNumb);
- foo (nNumb);
- }
- ////////////////////////////////////////////////////
- void swap(int *p1, int *p2) //
- {
- int n;
- n = *p1;
- *p1 = *p2;
- *p2 = n;
- }
- ////////////////////////////////////////////////////
- void sort(int *p)
- {
- int n,
- nF = 0;
- L_01: for(int i = 0; i < 19; i++)
- {
- if(p[i] > p[i+1])
- {
- nF = 1;
- swap(&p[i], &p[i+1]);
- }
- }
- if(nF == 1) {
- nF = 0;
- goto L_01;
- }
- }
- ////////////////////////////////////////////////////
- void foo(int *p)
- {
- for(int i = 0; i < 20; i++)
- {
- printf("%d, ", p[i]);
- }
- printf("\n");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement