#include<stdio.h>
int bubble(int x[],int n) {
int hold,j,pass,i,switched = 1;
for(pass = 0; pass < n-1 && switched == 1;pass++) {
switched=0;
for (j=0;j<n-pass-1;j++)
if (x[j]>x[j+1]) {
switched=1;
hold = x[j];
x[j] = x[j+1];
x[j+1]=hold;
}
}
return(0);
}
int main() {
int marks[10];
int i;
marks[0] = 39;
marks[1] = 55;
marks[2] = 43;
marks[2] = 43;
marks[3] = 49;
marks[4] = 12;
marks[5] = 2;
marks[6] = 5;
marks[7] = 4;
marks[8] = 3;
marks[9] = 1;
bubble(marks, 10);
for(i =0;i<10;i++){
printf("%d ",marks[i]);
}
}
|