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-2025 CODEPRJ.COM