Advertisement
Guest User

Untitled

a guest
Jan 19th, 2018
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. // 2. Sap xep cac ky tu cua chuoi theo thu tu bang chu cai
  2. // Goi y: Sap xep theo thuat toan doi cho
  3.  
  4. #include <stdio.h>
  5. #include <string.h>
  6.  
  7. int main()
  8. {
  9. char string[10000];
  10. char temp;
  11. int i,j;
  12. int n = strlen(string);
  13. scanf("%s", &string);
  14. printf("Chuoi ban dau : %s \n", string);
  15. for (i=0; i < n-1; i++)
  16. {
  17. for(j=i+1; j < n; j++)
  18. {
  19. if (string[i] > string[j])
  20. {
  21. temp = string[i];
  22. string[i] = string[j];
  23. string[j] = temp ;
  24. }
  25. }
  26. }
  27. printf("Chuoi sap xep : %s", string);
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement