帮我看下那里出错了,不能运行

tzhd2009 2013-01-23 12:18:06
#include<iostream.h>
double findmax(const double *pnumber,const int count){
double max=pnumber[0];
for(int i=0;i<count;i++)
{
if(max<pnumber[i])
{
max=pnumber[i];

}
}
return max;
}
double maximum(const double *pnumbers,const int count,double (*findmax)(const double *,const int)){
{
return findmax(pnumbers,count);
}
int main()
{
double numbers[]={12343.6,98938.4,12345.6,2485.33,95434.4};

int count=sizeof(numbers) / sizeof(double);
cout<<"the items in the array:"<<"\n";
for(int i=0;i<count;i++)
{
cout<<numbers[i]<<endl;
}
double maxvalue=maximum(numbers,count,findmax);
cout<<"the max value int the array is:"<<maxvalue<<endl;
return 1;
}




Compiling...
StdAfx.cpp
Compiling...
hyhyh.cpp
f:\hyhyh\hyhyh.cpp(19) : error C2601: 'main' : local function definitions are illegal
f:\hyhyh\hyhyh.cpp(32) : fatal error C1004: unexpected end of file found
执行 cl.exe 时出错.

hyhyh.exe - 1 error(s), 0 warning(s)
...全文
163 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
ardayoyo 2013-01-23
  • 打赏
  • 举报
回复
哦,对了,上面那个应该是减去一个左花括号 另外,不要让花括号紧挨着函数参数表,应该另起一行,并且保持缩进,就像这样

double maximum(const double *pnumbers,const int count,double (*findmax)(const double *,const int))
{
    return findmax(pnumbers,count);
}
这样不但整齐,也容易发现一些简单的括号不匹配的错误,切记
ardayoyo 2013-01-23
  • 打赏
  • 举报
回复
maximum函数末尾缺一个"}"

64,648

社区成员

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

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