Home > Back-end >  Bubble sort code
Bubble sort code

Time:06-07

Bubble sort:
#include
# define L 100
# define N 10
# define the From 5
# define End From + N - 1
Int main ()
{int a [L], k, y;
Printf (" do input % d Numbers \ n ", n);
For (y=the From; y<=End; Y++)
The scanf (" % d ", & amp; A [y]);
For (k=the From; K{the for (y=End; y>=k + 1; Y -)
{if (a [1] y & gt; A [y])
{a [0]=a, [1] y. A [1] y=a, [y]. A [y]=a, [0].
}
}
}
For (k=the From; K<=End; K++)
Printf (" % d ", a [k]);
return 0;
}

CodePudding user response:

What your problem is, there is no code function problem
You can put a [L] initialize a [L]={0}, and then in front of an empty array didn't quite understand (for the intermediate variables a [0]?) , not necessary

CodePudding user response:

I hope it can help you: https://blog.csdn.net/it_xiangqiang/category_10581430.html
I hope it can help you: https://blog.csdn.net/it_xiangqiang/category_10768339.html
  • Related