刚学编程 出现问题不知道什么意思 求高手解答
//**************************************
//*程序:E1_5.c *
//*输出三个数中的最大值 *
//* *
//*作者:刘雨双 *
//*时间:2011年9月18日 *
//* *
//*修改: *
//*时间 *
//**************************************
#include<stdio.h> //预编译命令
float max(floatx,floaty,floatz) //函数max,形参x,y,z
{float t; //定义变量t
if(x>y>z)t=x; //判断x、y、z关系,x大
if(x>z>y)t=x; //判断x、y、z关系,x大
if(y>x>z)t=y; //判断x、y、z关系,y大
if(y>z>x)t=y; //判断x、y、z关系,y大
else t=z; //判断x、y、z关系,z大
return t;} //返回t的值,结束
void main() //主函数
{float a,b,c,d; //定义变量a、b、c
d=max(a,b,c); //调用求max函数
scanf("%f,%f,%f,&a,&b,&c"); //键盘输入a、b、c、d
d=max(a,b,c); //强用求max函数
printf("%f,%f,%f,the max is %f\n",a,b,c,d); //输出信息
} //主函数结束
错误是
conversion from 'int' to 'float', possible loss of data
执行 cl.exe 时出错.
这是求三个数最大值
[解决办法]
type max( a, b, c );
type max(type a, type b, type c)
{
type tmp = a > b ? a : b;
return tmp > c ? tmp : c;
}
[解决办法]
没见过这么乱的 错误一大堆
#include <stdio.h>int MaxInt( int a, int b, int c ){ return (( ( a > b ) ? a : b ) > c ) ? ( ( a > b ) ? a : b ) : c;}int main(){ int a,b,c; scanf("%d %d %d",&a,&b,&c); printf("%d\n",MaxInt(a,b,c)); return 0;}//int的 float的自己写吧
[解决办法]
scanf("%f,%f,%f,&a,&b,&c"); //键盘输入a、b、c、d
应该是scanf("%f,%f,%f“,&a,&b,&c);
[解决办法]
scanf("%f,%f,%f,&a,&b,&c"); //键盘输入a、b、c、d
应该是scanf("%f,%f,%f",&a,&b,&c);