fork download
  1. #include <stdio.h>
  2.  
  3. #define TRUE 1
  4. #define FALSE 0
  5. #define numbers 50
  6. main()
  7. {
  8. int data[numbers]={57,84,35,16,47,89,55,63,25,42};
  9. int i,j,n=10,temp,ok;
  10. for(i=0;i<n;i++)
  11. {
  12. printf("N%d=%d\t",i+1,data[i]);
  13. }
  14. printf("\nthe sorted data-->\n");
  15. for(i=n-1;i>=1;i--)
  16. {
  17. ok=TRUE;
  18. for(j=0;j<i;j++)
  19. if(data[j]>data[j+1])
  20. {
  21. temp=data[j];
  22. data[j]=data[j+1];
  23. data[j+1]=temp;
  24. ok=FALSE;
  25. }
  26. if(ok)
  27. i=0;
  28. }
  29. for(i=0;i<n;i++)
  30. printf("%5d",data[i]);
  31. printf("\n");
  32. }
  33.  
Success #stdin #stdout 0s 10320KB
stdin
Standard input is empty
stdout
N1=57	N2=84	N3=35	N4=16	N5=47	N6=89	N7=55	N8=63	N9=25	N10=42	
the sorted data-->
   16   25   35   42   47   55   57   63   84   89