雖然說求最大值最小值函數(shù)在哪個頭文件下并不是非常重要,但是遇到問題的時候我們很快的找到~~ MSDN上說在algorithm下,但是出錯了,其實這兩個函數(shù)需要包含兩個頭文件<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;
}
運行結果如下:
posted on 2010-09-14 15:59
jince 閱讀(27638)
評論(4) 編輯 收藏 引用 所屬分類:
學習到的一些小知識