求三个数最大数的程序.为什么结果不对?

[复制链接]
查看11 | 回复2 | 2008-9-20 10:54:33 | 显示全部楼层 |阅读模式
#include
double tmax(double x,double y,double z){
if(x>y){if(x>z) return x; else return z;}
else {if(y>z) return y; else return z;}}
void main()
{double x,y,z;
scanf("%f,%f,%f",&x,&y,&z);
printf("tmas is %f.\n",tmax(x,y,z));}

回复

使用道具 举报

千问 | 2008-9-20 10:54:33 | 显示全部楼层
经过修改之后的: #include double tmax(double x,double y,double z) { if(x>y) {if(x>z) return(x); else return (z);} else {if(y>z) return y; else return (z);} } void main() {double x,y,z; scanf("%lf,%lf,%lf",&x,&y,&z); printf("tmas is %f.\n",tmax(x,y,z)); } 无法正确的显示,是因为double函数的格式字符是lf,在输出的时候%f...
回复

使用道具 举报

千问 | 2008-9-20 10:54:33 | 显示全部楼层
得到...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行