想用min 和max 函数要包含哪个文件?

WuYL7812 2004-10-09 10:24:56
这两个函数是在std名字空间里的吗?
...全文
3640 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
WuYL7812 2004-10-10
  • 打赏
  • 举报
回复
靠,我想也是在<algorigthm里,但是用VC6.0就是编译不通过
以后不用VC6.0了
winter_bear 2004-10-09
  • 打赏
  • 举报
回复
#include<stdlib.h>
pacman2000 2004-10-09
  • 打赏
  • 举报
回复
呵呵,是的!好像是模板函数。
短歌如风 2004-10-09
  • 打赏
  • 举报
回复
#include <algorithm>
NC217 2004-10-09
  • 打赏
  • 举报
回复
long max_min(long *p1,long *p2)
{return (*p1>*p2?p1:p2);}

这样简单点。。。。。。。。。
aiguo26 2004-10-09
  • 打赏
  • 举报
回复
#include <algorith>
#include <iostream>
using namespace std;
int main()
{ cout<<min(2,3)<<endl;
cout<<max(2,3)<<endl;
cin.get();
}
短歌如风 2004-10-09
  • 打赏
  • 举报
回复
#include <algorithm>
#include <iostream>

int main()
{
std::cout << std::min(2,3) << "\n" << std::max(2,3) << std::endl;
std::cin.get();
}
输出:
2
3


Dev C++4.9.9.0
  • 打赏
  • 举报
回复
自己写一个也不难
template<typename T>
T max(const T& t1,const T& t2)
{
return t1>t2?t1:t2;
}

template<typename T>
T min(const T& t1, const T& t2)
{
return t1<t2?t1:t2;
}
  • 打赏
  • 举报
回复
应该是stdlib
WuYL7812 2004-10-09
  • 打赏
  • 举报
回复
我#include <algorithm>
min和max都不能用呀,谁给我完整的代码?
std::min也不行

64,677

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧