如何用C语言编程将字符串s中的所有字符按ASCII值从小到大重新排序后输出字符串?

2024-11-16 16:22:45
推荐回答(1个)
回答1:

#include "string.h"

int main()

{char s[100],t;

int i,j,sum;

printf("Input:\n");

gets(s);

sum=strlen(s);

for(i=0;i

for(j=0;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;
}