输入三个数,求最大数

Jerrylearnc 2008-07-02 05:25:23
/*输入三个数,求最大数*/
#include<stdio.h>
main()
{
int a,b,c,z,max;
printf("Input a,b,c\n");
scanf("%d%d%d",&a,&b,&c);
z=a>b?a:b;
max=z>c?z:c;
printf("The biggest of a,b,c is:%d",max);
getch();
return 0;
}
做的课后练习题
不知道这样做对不对
...全文
447 37 打赏 收藏 转发到动态 举报
写回复
用AI写文章
37 条回复
切换为时间正序
请发表友善的回复…
发表回复
eiyuan 2008-12-21
  • 打赏
  • 举报
回复
怎么不能编译呢
rangzh 2008-07-03
  • 打赏
  • 举报
回复
dui
chen_hello88 2008-07-03
  • 打赏
  • 举报
回复
#include <stdio.h>

int max(int x,int y)
{
int mx;
mx=x>y?x:y;
return mx;
}
main()
{
int max( int x,int y);
{
int a,b,c,result;
printf("/nPlease input 3 number:");
scanf("%d%d%d",&a,&b,&c);
result=max(a,max(b,c));
printf("The max of%d%d%d is %d\n",result);
getch();
}
fengdream 2008-07-03
  • 打赏
  • 举报
回复
int max(int a,int b, int c)
{
return (a>b?a:b)>c?(a>b?a:b):c;
}
int main()
{
printf("max %d", max(1,2,3));
}
daixiang 2008-07-03
  • 打赏
  • 举报
回复
我喜欢7楼的程序
huzl1986 2008-07-03
  • 打赏
  • 举报
回复
上机运行不久解决了吗
lijpbasin 2008-07-03
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 clhposs 的回复:]
C/C++ code#include<stdio.h>#definemax(a,b) (a>b?a:b)intmain()
{intv1,v2,v3;
printf("输入3个数字");
scanf("%d%d%d",&v1,&v2,&v3);
printf("max=%d",max(max(v1,v2),max(v2,v3)));return0;
}
[/Quote]
C在函数调用的时候一定是先计算右边的参数吗?
shancao 2008-07-03
  • 打赏
  • 举报
回复
#include<iostream>
using namespace std;
int max(int a,int b,int c)
{
int max=a;
if(a<b)
{
max=b;
if(b<c)
max=c;
}
else
if(a<c)
{
max=c;
if(b>c)
max=b;
}

return max;

}
void main()
{
int a,b,c;
cout<<"请输入三个数"<<endl;
cin>>a>>b>>c;
cout<<"最大数"<<max(a,b,c)<<endl;
}
虽然效率不高,但是容易理解。呵呵.你的也没有错误,只要把getc()去丢就可以啦。呵呵
fallening 2008-07-03
  • 打赏
  • 举报
回复
conio.h 不在c标准中,注意,如果acm中出现的话,注定失败的。
Jerrylearnc 2008-07-03
  • 打赏
  • 举报
回复
[Quote=引用 28 楼 clhposs 的回复:]
引用 27 楼 Jerrylearnc 的回复:
引用 20 楼 cumt_TTR 的回复:
开头是不是少了个这个
#include <conio.h>

#include <conio.h>
这个是做什么用的
我知道它是预处理
但是在这个程序中它有什么用途
谢谢
非常感谢

如果程序使用了
getch();这个函数那么 就需要包含
#include <conio.h>

conio.h 标准库
[/Quote]

但是我没写conio.h
程序也能运行啊
这是怎么回事
以前我在使用clrscr()函数的时候 也没写包含它的库 也能编译成功
这是怎么回事
谢谢
非常感谢
xiaoliang_c 2008-07-03
  • 打赏
  • 举报
回复
我也做过这个题 楼主上机跑一趟吧!
clhposs 2008-07-03
  • 打赏
  • 举报
回复
[Quote=引用 27 楼 Jerrylearnc 的回复:]
引用 20 楼 cumt_TTR 的回复:
开头是不是少了个这个
#include <conio.h>

#include <conio.h>
这个是做什么用的
我知道它是预处理
但是在这个程序中它有什么用途
谢谢
非常感谢
[/Quote]
如果程序使用了
getch();这个函数那么 就需要包含
#include<conio.h>

conio.h 标准库
Jerrylearnc 2008-07-03
  • 打赏
  • 举报
回复
[Quote=引用 20 楼 cumt_TTR 的回复:]
开头是不是少了个这个
#include <conio.h>
[/Quote]
#include <conio.h>
这个是做什么用的
我知道它是预处理
但是在这个程序中它有什么用途
谢谢
非常感谢
a88192 2008-07-03
  • 打赏
  • 举报
回复
这也来问????
你不知道自己去跑跑??
jeremy0822 2008-07-03
  • 打赏
  • 举报
回复
上机跑跑就是了jf
jeremy0822 2008-07-03
  • 打赏
  • 举报
回复
上机跑跑就是了jf
shilf 2008-07-02
  • 打赏
  • 举报
回复
课本上有的吧?
cumt_TTR 2008-07-02
  • 打赏
  • 举报
回复
开头是不是少了个这个
#include <conio.h>
yyyapple 2008-07-02
  • 打赏
  • 举报
回复
jf

#include<stdio.h>

#define MAX(a, b, c) getmax(getmax(a,b), c)
int getmax(int a, int b)
{
return (a>b)?a:b;
}


int main()
{
int v1,v2,v3;
printf("输入3个整数\n");
scanf("%d %d %d",&v1,&v2,&v3);
printf("max=%d\n", MAX(v1, v2, v3));
getchar();
return 0;
}
Thirty 2008-07-02
  • 打赏
  • 举报
回复
#include <stdio.h>

int main()
{
int a,b,c;
int max;
scanf("%d,%d,%d",&a,&b,&c);
max=(a>b)?((a>c)?a:c):((b>c)?b:c);
printf("max=%d\n",max);
return 0;
}
加载更多回复(17)

69,373

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧