C语言:min和max头文件

来源:互联网 发布:手机游戏双开软件 编辑:程序博客网 时间:2024/06/10 19:46
转自:http://www.cppblog.com/jince/archive/2010/09/14/126600.html
min和max头文件
            虽然说求最大值最小值函数在哪个头文件下并不是非常重要,但是遇到问题的时候我们很快的找到~~  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;
}
原创粉丝点击