fork download
  1. #include<stdio.h>
  2. void bubblesort(int a[],int N);
  3. int i;
  4. int main()
  5. {
  6. int N=6;
  7. int a[]={2,7,4,1,9,3};
  8. bubblesort(a,N);
  9. //int i;
  10. // for(i=0;i<N;i++)
  11. //{
  12. // printf("%d\t",a[i]);
  13. //}
  14. return 0;
  15. }
  16. void bubblesort(int a[],int N)
  17. {
  18. for(i=0;i<N-1;i++)
  19. {
  20. if(a[i]>a[i+1])
  21. {
  22. int temp;
  23. temp=a[i];
  24. a[i]=a[i+1];
  25. a[i+1]=temp;
  26. }
  27. int j;
  28. for(j=0;j<N;j++)
  29. {
  30. printf("%d\t",a[i]);
  31. }
  32. printf("\n");
  33. }
  34. }
Success #stdin #stdout 0s 9424KB
stdin
Standard input is empty
stdout
2	2	2	2	2	2	
4	4	4	4	4	4	
1	1	1	1	1	1	
7	7	7	7	7	7	
3	3	3	3	3	3