You are viewing a single comment's thread. Return to all comments →
int main() { int a[1000000],n,i,j,temp,count=0; scanf("%d",&n); for(i=0;ia[j+1]) {count++; temp=a[j]; a[j]=a[j+1]; a[j+1]=temp; }}} printf("Array is sorted in %d swaps.\n",count); printf("First Element: %d\n",a[0]); printf("Last Element: %d\n",a[n-1]); return 0; }
Seems like cookies are disabled on this browser, please enable them to open this website
Sorting: Bubble Sort
You are viewing a single comment's thread. Return to all comments →
include
int main() { int a[1000000],n,i,j,temp,count=0; scanf("%d",&n); for(i=0;ia[j+1]) {count++; temp=a[j]; a[j]=a[j+1]; a[j+1]=temp; }}} printf("Array is sorted in %d swaps.\n",count); printf("First Element: %d\n",a[0]); printf("Last Element: %d\n",a[n-1]); return 0; }