class-notes/2208/C语言/源码/字符串-2.c
2025-03-14 11:18:41 +08:00

25 lines
313 B
C

#include <stdio.h>
#include <string.h>
int main(){
char str[100];
char temp;
int i, j;
gets(str);
for(i=0;i<strlen(str)-1;i++){
for(j=0;j<strlen(str)-1-i;j++){
if(*(str+j) > *(str+j+1)){
temp = *(str+j);
*(str+j) = *(str+j+1);
*(str+j+1) = temp;
}
}
}
puts(str);
return 0;
}