#include <stdio.h> void main() { char xx[80] ; int numi,numj; char ch; printf("\n please input strings:"); scanf("%s",xx); for (numi=0;numi<strlen(xx);numi++) /***************found***************/ for (numj=0;numj<strlen(xx);numj++) if (xx[numi]<xx[numj]){ /***************found***************/ ___2___; xx[numi]=xx[numj]; /***************found***************/ ___3___;} printf("\n %s",xx); }
时间: 2023-06-29 12:01:57 浏览: 167
#include <stdio.h>
void main() {
char xx[80];
int numi, numj;
char ch;
printf("\n please input strings:");
scanf("%s", xx);
for (numi=0; numi<strlen(xx); numi++) {
for (numj=numi+1; numj<strlen(xx); numj++) { // 修改1:numj 的起始值为 numi+1
if (xx[numi]>xx[numj]) { // 修改2:改为 xx[numi]>xx[numj]
ch = xx[numi];
xx[numi] = xx[numj];
xx[numj] = ch;
}
}
}
printf("\n %s", xx);
}
阅读全文