想用冒泡写一下这个排序,感觉这个输出有点莫名其妙的,各位大佬看出来了吗?
这是源码:
#include <stdio.h>
int main()
{
int i,j;
char a[3],temp;
while(scanf("%c%c%c",&a[0],&a[1],&a[2])!=EOF)
{
for(i=0;i<3-1;i++)
{
for(j=0;j<3-i-1;j++)
{
if(a[j]>a[j+1])
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
printf("%c %c %c\n",a[0],a[1],a[2]);
}
return 0;
}