c语言输入3个整数,从小到大排序后输出。

#include <stdio.h>

int main()
{ int a,b,c,t;
while(scanf("%d%d%d",&a,&b,&c)!=EOF)
{
if(a<b)
else {t=a;b=t;a=b;}
if(a<c)
else {t=a;c=t;a=c;}
if(b<c)
else {t=b;c=t;b=c;}
printf("%d %d %d\n",a,b,c);
}
return 0;
}
编译的时候提示illegal else without matching if 怎么改正?

#include <stdio.h>

int main()
{     int a,b,c,t;
      while(scanf("%d%d%d",&a,&b,&c)!=EOF)
      {  
          if(a>b) //改成>
 {t=a;a=b;b=t;} //elae删掉 赋值语句也换一下
          if(a>c)
{t=a;a=c;c=t;}//elae删掉 赋值语句也换一下
          if(b>c)
 {t=b;b=c;c=t;}//赋值语句换一下
           printf("%d %d %d\n",a,b,c);  
      }
 return 0;
}

温馨提示:答案为网友推荐,仅供参考
第1个回答  2013-10-17
把else都删掉,if后跟的是处理方法,不是else。
第2个回答  推荐于2017-11-26
少了几个;赋值语句也有些问题。
程序如下,编译通过。
#include <stdio.h>
int main()
{ int a,b,c,t;
while(scanf("%d%d%d",&a,&b,&c)!=EOF)
{
if(a<b) ;
else {t=b;b=a;a=t;}
if(a<c);
else {t=c;c=a;a=t;}
if(b<c);
else {t=c;c=b;b=t;}
printf("%d %d %d\n",a,b,c);
}
return 0;
}本回答被提问者采纳
第3个回答  2013-10-17
if(a<b)
{t=a;b=t;a=b;}
else if(a<c)
{t=a;c=t;a=c;}
else if(b<c)
{t=b;c=t;b=c;}