fork(5) download
  1. // Question:2 Sort Again
  2.  
  3. #include <stdio.h>
  4. #include <string.h>
  5.  
  6. void bubble(char *x, char *y);
  7. int main()
  8. {int j=0;
  9. char sort[300];
  10. scanf("%s", sort);
  11.  
  12. int string = strlen(sort);
  13.  
  14.  
  15. for (int i= 0; i< string; i ++)
  16. {
  17. if (sort[j] < sort[j + 1])
  18. {
  19. bubble(&sort[j], &sort[j -1]);
  20.  
  21. printf ( " %d ", i);
  22. printf ( " %s",sort);
  23. return 0;
  24. }}}
  25.  
  26. void bubble(char *x, char *y)
  27. {
  28. int temp = *x;
  29. *x = *y;
  30. *y = temp;
  31. }
  32.  
Success #stdin #stdout 0s 5380KB
stdin
abddccss
stdout
 0