fork download
  1. #include<stdio.h>
  2. #include<string.h>
  3. //#include<cs50.h>
  4. #include<math.h>
  5. #include<stdlib.h>
  6. #include<ctype.h>
  7.  
  8. void sort(char* input)
  9. {
  10. const int length = strlen(input);
  11. int j = length -1;
  12. char temp[length];
  13. for(int i=0; i<length; i++)
  14. {
  15. temp[i]= *(input+i);
  16. }
  17.  
  18. while(j)
  19. {
  20. if((int)*(input+1) < (int)*(input))
  21. {
  22. char temp1;
  23. temp1 = *(input);
  24. *input = *(input + 1);
  25. *(input + 1) = temp1;
  26. }
  27. input++;
  28. j--;
  29. }
  30. input = input - length +1;
  31. for(int k=0; k<length; k++)
  32. {
  33. if(temp[k]!=*(input+k))
  34. {
  35. sort(input);
  36. }
  37. }
  38. }
  39. int main()
  40. {
  41. char* input = malloc(sizeof(char)*1000);
  42. scanf("%[^\n]%*c",input);
  43. sort(input);
  44. printf("%s",input);
  45. return 0;
  46. }
  47.  
Success #stdin #stdout 0s 2304KB
stdin
ccbbaa
stdout
aabbcc