输入一行字符,将其中的字符从小到大排列后输出。

2025年03月01日 10:11
有2个网友回答
网友(1):

C用个冒泡就可以了
N=strlen(str);
for (i=0;i for (j=0;j if(str[j]>str[j+1])
{
t=str[j];
str[j]=str[j+1];
str[j+1]=t;
}

网友(2):

VB代码如下
for i=1 to len(mystring)
pp(i)=mid(mystring,i,1)
next i
for i = 1 to len(mystring)-1
for ii= i+1 to len(mystring)
if pp(i)>pp(ii) then
temptstring=pp(i)
pp(i)=pp(ii)
pp(ii)=temptstring
end if
next ii
next i
temptstring=""
for i=1 to len(mystring)
temptstring=temptstring+pp(i)
next i
'现在temptstring变量里面存的就是你想要的了在不在数组pp()里面也是
变量未定义自己看着点儿哈!!