接受两个参数:一个是int型的数,另一个是int指针,求其中最大值,琢磨好久不解,求大神指教

prehension 2014-04-02 09:13:57
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
string low_upperletters( string &s);
int main(){
cout<<"please enter two integers ";
int a,b,y;
cin>>a>>b;
cout<<a<<b<<endl;
y=_MAX(a,&b);
cout<<y<<endl; //加一句输出。
return 0;
}

int _MAX (int a,int*p)
{
return((a>*p)?a:*p);

}
...全文
224 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
meinanjing 2014-04-03
  • 打赏
  • 举报
回复
buyong 2014-04-03
  • 打赏
  • 举报
回复
引用 6 楼 u014387206 的回复:
我已经找到答案了,函数没声明就使用了,谢谢各位的回答
prehension 2014-04-03
  • 打赏
  • 举报
回复
我已经找到答案了,函数没声明就使用了,谢谢各位的回答
prehension 2014-04-02
  • 打赏
  • 举报
回复
#include<iostream> #include<string> #include<algorithm> using namespace std; int main(){ cout<<"please enter two integers "; int a,b,y; cin>>a>>b; cout<<a<<b<<endl; y=_MAX(a,&b); cout<<y<<endl; //加一句输出。 return 0; } int _MAX (int a, int *p) { return((a>(*p))?a:(*p)); } error C3861: “_MAX”: 找不到标识符 还有是不是int _MAX (int a, int const *p)只能接受同种类型的,用什么方式才能把_MAX ()的参数变成一种形式
碼上道 2014-04-02
  • 打赏
  • 举报
回复
引用 楼主 u014387206 的回复:
#include<iostream> #include<string> #include<algorithm> using namespace std; string low_upperletters( string &s); int main(){ cout<<"please enter two integers "; int a,b,y; cin>>a>>b; cout<<a<<b<<endl; y=_MAX(a,&b); cout<<y<<endl; //加一句输出。 return 0; } int _MAX (int a,int*p) { return((a>*p)?a:*p); }
没有看出问题所在
max_min_ 2014-04-02
  • 打赏
  • 举报
回复
就代码而已,看不出来有什么额外的需求啊!
JiMoKuangXiangQu 2014-04-02
  • 打赏
  • 举报
回复
引用 楼主 u014387206 的回复:
#include<iostream> #include<string> #include<algorithm> using namespace std; string low_upperletters( string &s); int main(){ cout<<"please enter two integers "; int a,b,y; cin>>a>>b; cout<<a<<b<<endl; y=_MAX(a,&b); cout<<y<<endl; //加一句输出。 return 0; } int _MAX (int a,int*p) { return((a>*p)?a:*p); }
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

//string low_upperletters(string &s); // 什么情况这是???
int _MAX(int a, int* p);

int main(){
	cout << "please enter two integers ";
	int a, b, y;
	cin >> a >> b;
	cout << a << b << endl;
	y = _MAX(a, &b);
	cout << y << endl;     //加一句输出。

	return 0;
}

int _MAX(int a, int* p)
{
	return ((a > *p) ? a : *p);
}
有什么问题吗?
turing-complete 2014-04-02
  • 打赏
  • 举报
回复
我也不解为什么要这么做。

65,208

社区成员

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

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