1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
#include<stdio.h> #include<conio.h> int main() { int a[10]={}; int temp,j,i,x; printf("Please Enter Array element MAX:10n"); for(i=0; i<=9; i++) { scanf("%d",&a[i]); } printf("nn Unsorted Array is :"); for(i=0; i<9; i++) { printf(" n a[%d]= %d",i,a[i]); } for(j=0; j<=9; j++) { for(i=0; i<=9-j; i++) { if(a[i] >= a[i+1]) { temp=a[i]; a[i]=a[i+1]; a[i+1]=temp; } } printf("nn Iteration %d :",j); for(x=0; x<=9; x++) { printf(" %d ",a[x]); } } printf("nn Sorted Array is :"); for(i=0; i<=9; i++) { printf(" %d ",a[i]); } getch(); } |