作业帮 > 综合 > 作业

max(max(a,b),c)应该怎么用啊

来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/05/08 02:44:31
max(max(a,b),c)应该怎么用啊
#include
#include
int main()
{
int a,b,c;
scanf ("%d%d%d",&a,&b,&c);
printf ("%d",a+b+c);
printf ("%.0lf",(a+b+c)/3);
max(max(a,b),c);
return 0;
}
--------------------Configuration:text - Win32 Debug--------------------
Compiling...
book.cpp
C:\Program Files\Microsoft Visual Studio\MyProjects\text\book.cpp(9) :error C2065:'max' :undeclared identifier
Error executing cl.exe.
book.obj - 1 error(s),0 warning(s)
错误原因:该宏没有定义
#include
使用__max函数代替max
在stdlib.h中有关max定义如下:
/* Non-ANSI names for compatibility */
#ifndef __cplusplus
#define max(a,b) (((a) > (b)) ? (a) : (b))
#define min(a,b) (((a) < (b)) ? (a) : (b))
#endif