6.3w+
社区成员
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 }