C语言简单问题

[复制链接]
查看11 | 回复5 | 2009-1-30 21:48:03 | 显示全部楼层 |阅读模式
我真是菜鸟了
小小问题问一下
double max(double x, double y,double z);
main()
{
printf("please input three numbers and output the max one\n");
double a,b,c,d;
scanf("%lf,%lf,%lf",&a,&b,&c);
d=max(a,b,c);
printf("%lf",d);
return main();
}
double max(double x, double y, double z)
{
if (x>y and x>z) then return(x);
if (y>x and y>z) then retuan(y);
if (z>x and z>y) then retuan(z);
}
这段程序到底错了多少啊!……汗ing

回复

使用道具 举报

千问 | 2009-1-30 21:48:03 | 显示全部楼层
#include//加上头文件double max(double x, double y,double z); int main() //标准写法{ printf("please input three numbers and output the max one\n"); double a,b,c,d; scanf("%lf,%lf,%lf",&a,&b,&c); d=max(a,b,c); printf("%lf",d); return 0;//同上} double max(double x, double y, double z) { if (x>y && x>z)retu...
回复

使用道具 举报

千问 | 2009-1-30 21:48:03 | 显示全部楼层
1,主函数用void main() 不要返回值了。 2,双精度double输出,%f不是%lf,只有输入时是%lf。 3,函数 max()中有误, 不能x>y and x>z而要x>y&&x>z。而且C中没有if() then的语句,不能有then,和vb可不一样。 修改如下: #include "stdio.h" double max(...
回复

使用道具 举报

千问 | 2009-1-30 21:48:03 | 显示全部楼层
#include double max(double x, double y,double z); main() { printf("please input three numbers and output the max one\n"); double a,b,c,d; scanf("%lf,%lf,%lf",&...
回复

使用道具 举报

千问 | 2009-1-30 21:48:03 | 显示全部楼层
你是学c语言的吗...
回复

使用道具 举报

千问 | 2009-1-30 21:48:03 | 显示全部楼层
#includedouble max(double x, double y,double z); void main() { printf("please input three numbers and output the max one\n\n"); double a,b,c,d; scanf_s("%lf,%l...
回复

使用道具 举报

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

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行