> 其他 >
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)
人气:340 ℃ 时间:2020-02-05 11:36:52
解答
错误原因:该宏没有定义
#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
推荐
猜你喜欢
© 2024 79432.Com All Rights Reserved.
电脑版|手机版