about

jianfengshxy 2008-03-16 05:21:04

1 #include<iostream>
2 #include<algorithm>
3 #include<vector>
4 using namespace std;
5 int main()
6 {
7 vector<int> ivec;
8 int ival;
9 int sum=0;
10 cout<<"input the elements of vector:"<<endl;
11 while(cin>>ival)
12 ivec.push_back(ival);
13
14 cout<<"the sum of the vector:";
15 cout<<accumulate(ivec.begin(),ivec.end(),0)<<endl;
16 }


1103.cc: In function `int main()':
1103.cc:15: `accumulate' undeclared (first use this function)
1103.cc:15: (Each undeclared identifier is reported only once for each function
it appears in.)



...全文
43 3 打赏 收藏 举报
写回复
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
我啃 2008-03-16
  • 打赏
  • 举报
回复
#include <numeric>
不再algorithm里面
我啃 2008-03-16
  • 打赏
  • 举报
回复
using namespace std;
或者用
std::
jianfengshxy 2008-03-16
  • 打赏
  • 举报
回复
1 #include<iostream>
2 #include<algorithm>
3 #include<vector>
4 using namespace std;
5 int main()
6 {
7 vector<int> ivec;
8 int ival;
9 int sum=0;
10 cout<<"input the elements of vector:"<<endl;
11 while(cin>>ival)
12 ivec.push_back(ival);
13
14 cout<<"the sum of the vector:";
15 cout<<accumulate(ivec.begin(),ivec.end(),0)<<endl;
16 }
17
~
发帖
C++ 语言

6.3w+

社区成员

C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
帖子事件
创建了帖子
2008-03-16 05:21
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下