fork download
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <stdlib.h>
  4.  
  5.  
  6. void Sort(char m[10],int n);
  7. int main()
  8. {
  9. int i,n;
  10.  
  11. char name[10];
  12. printf("输入单词:");
  13. scanf("%s",&name[0]);
  14. n = strlen(name);
  15.  
  16. Sort(name,n);
  17.  
  18. for(i=0;i<n;i++)
  19. {
  20. printf("%c",name[i]);
  21. }
  22.  
  23. return 0;
  24. }
  25.  
  26. void Sort(char m[10],int n)
  27. {
  28. int i,j;
  29. char temp;
  30.  
  31. for(i=0;i<n-1;i++)
  32. {
  33.  
  34. for(j=i+1;j<n;j++)
  35. {
  36. if(m[j]<m[i])
  37. {
  38. temp=m[i];
  39. m[i]=m[j];
  40. m[j]=temp;
  41. }
  42. }
  43. }
  44. }
Success #stdin #stdout 0s 3416KB
stdin
apple
stdout
输入单词:aelpp