Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void fun(int a[], int n) {
- int i, j;
- int temp;
- for (i = n - 1; i > 0; i--) {
- for (j = 0; j < i; j++) {
- if (n%2 == 1) {
- if (a[j] > a[j+1]) {
- temp = a[j];
- a[j] = a[j+1];
- a[j+1] = temp;
- }
- }
- else if (n%2 == 0) {
- if (a[j] < a[j+1]) {
- temp = a[j];
- a[j] = a[j+1];
- a[j+1] = temp;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement