C語言:min和max頭文件


轉自: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;
}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2026 CODEPRJ.COM