fork 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. {
  9. char sort[300];
  10. scanf("%s", sort);
  11.  
  12. int string = strlen(sort);
  13. for (int i = 1; i <= string; i++)
  14. {
  15. for (int j = 0; j < string - i; j++)
  16. {
  17. if (sort[j] < sort[j + 1])
  18. {
  19. bubble(&sort[j], &sort[j + 1]);
  20. }
  21. }
  22. }
  23.  
  24. puts(sort);
  25. return 0;
  26. }
  27.  
  28. void bubble(char *x, char *y)
  29. {
  30. int temp = *x;
  31. *x = *y;
  32. *y = temp;
  33. }
  34.  
Success #stdin #stdout 0s 5548KB
stdin
BlackBerry1234567890???
stdout
yrrlkecaBB???9876543210