[求助]函数不声明会产生什么结果?
#include<stdio.h>main()
{float a,b;
int c;
scanf("%f,%f,",&a,&b);
c=max(a,b);
printf("Max is %d\n",c);
}
max(float x,float y)
{float z;
z=x>y?x:y;
return(z);
}
输入2.5,1.5 tc输出结果却是1,vc输出结果是2,为什么?
如果改成
#include<stdio.h>
max(float x,float y)
{float z;
z=x>y?x:y;
return(z);
}
main()
{float a,b;
int c;
scanf("%f,%f,",&a,&b);
c=max(a,b);
printf("Max is %d\n",c);
}
结果是2,应该和声明有关,但不知道原因是什么
main()
{int a,b,c;
scanf("%d,%d",&a,&b);
c=max(a,b);
printf("Max is %d\n",c);
}
max(int x,int y)
{int z;
z=x>y?x:y;
return(z);
}这个程序的输出结果也是2,很难理解?
[此贴子已经被作者于2007-4-23 22:04:30编辑过]