输入字符串给s将字符串s中的所有字符按ASCII值从小到大重新排序后,将排序后的字符串输出。
第1个回答 2019-01-02
![](https://video.ask-data.xyz/img.php?b=https://iknow-pic.cdn.bcebos.com/bf096b63f6246b605a7b62f6e6f81a4c510fa23f?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_600%2Ch_800%2Climit_1%2Fquality%2Cq_85%2Fformat%2Cf_auto)
#include <stdio.h>
#include <string.h>
int main()
{
char s[100] = {0},t;
int i,j,sum;
printf("Input:\n");
gets(s);
sum=strlen(s);
for(i=0;i<sum-1;i++)
for(j=0;j<sum-i-1;j++)
if(s[j+1]<=s[j])
{
t=s[j];
s[j]=s[j+1];
s[j+1]=t;
}
printf("Output:\n");
puts(s);
return 0;
}
本回答被网友采纳