为啥说1.cpp(21) : error C2181: illegal else without matching if
#include<stdio.h>void fun(float*x,float*y,float*z)
{
float k;
if(*x>*y)
{
if(*y<*z)
{
if(*z>*x)
k=*x;*x=*z;*z=*y;*y=k;
else k=*z;*z=*y;*y=k;
}
else *x=*x;*y=*y;*z=*z;
}
else
{
if(*y>*z)
{
if(*x>*z)
k=*x;*x=*y;*y=k;
else k=*x;*x=*y;*y=*z;*z=k;
}
else k=*x;*x=*z;*z=k;
}
}
void main()
{
float a,b,c;
printf("请输入三个数:\n");
scanf("%f%f%f\n",&a,&b,&c);
printf("a=%f b=%f c=%f\n",a,b,c);
fun(&a,&b,&c);
printf("a=%f b=%f c=%f\n",a,b,c);
}
--------------------Configuration: c语言 - Win32 Debug--------------------
Compiling...
1.cpp
C:\Users\Administrator\Desktop\lx\c语言\1.cpp(11) : error C2181: illegal else without matching if
C:\Users\Administrator\Desktop\lx\c语言\1.cpp(21) : error C2181: illegal else without matching if
执行 cl.exe 时出错.
1.obj - 1 error(s), 0 warning(s)
为什么说1.cpp(11) : error C2181: illegal else without matching if
1.cpp(21) : error C2181: illegal else without matching if
求教高手,谢谢