AC code:
#include<string.h>
#define N 3
void swap(char *a,char *b)
{
char temp;
temp=*a;
*a=*b;
*b=temp;
}
void sort(char a[])
{
char *p;
p=a;
if(a[0]>a[1])
swap(p,p+1);
if(a[0]>a[2])
swap(p,p+2);
if(a[1]>a[2])
swap(p+1,p+2);
}
int main()
{
int i;
char str[5];
while(gets(str))
{
sort(str);
for(i=0; i<3; i++)
{
if(i<2)
printf("%c ",str[i]);
else
printf("%c",str[i]);
}
printf("\n");
}
return 0;
}
转载于:https://www.cnblogs.com/cpoint/archive/2011/04/13/2015340.html
361


ASCII码排序&spm=1001.2101.3001.11974&articleId=101806900&d=1&t=3&u=abfde7e4370c4cda98afade43614e42e)

被折叠的 条评论
为什么被折叠?



