Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // 2. Sap xep cac ky tu cua chuoi theo thu tu bang chu cai
- // Goi y: Sap xep theo thuat toan doi cho
- #include <stdio.h>
- #include <string.h>
- int main()
- {
- char string[10000];
- char temp;
- int i,j;
- int n = strlen(string);
- scanf("%s", &string);
- printf("Chuoi ban dau : %s \n", string);
- for (i=0; i < n-1; i++)
- {
- for(j=i+1; j < n; j++)
- {
- if (string[i] > string[j])
- {
- temp = string[i];
- string[i] = string[j];
- string[j] = temp ;
- }
- }
- }
- printf("Chuoi sap xep : %s", string);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement