轉自:http://www.cppblog.com/jince/archive/2010/09/14/126600.html
雖然說求最大值最小值函數在哪個頭文件下並不是非常重要,但是遇到問題的時候我們很快的找到~~ MSDN上說在algorithm下,但是出錯了,其實這兩個函數需要包含兩個頭文件<windows.h>和<windef.h>文件,其他的還有__min和__max需要包含<stdlib.h>頭文件。。
#include
<
iostream
>
#include
<
windows.h
>
#include
<
stdio.h
>
#include
<
windef.h
>
using
namespace
std;
int
main ()
{
cout << "max(1,2)==" << max(1,2) << endl;
cout << "max(2,1)==" << max(2,1) << endl;
cout << "max('a','z')==" << max('a','z') << endl;
cout << "max(3.14,2.72)==" << max(3.14,2.72) << endl;
cout << "max(1,2)==" << __max(1,2) << endl;
cout << "max(2,1)==" << __max(2,1) << endl;
cout << "max('a','z')==" << __max('a','z') << endl;
cout << "max(3.14,2.72)==" << __max(3.14,2.72) << endl;
return 0;
}
