summation of vector containing long long int using accumulation
问题 #include <iostream> #include <vector> #include <numeric> #include <iterator> using namespace std; int main() { int N; cin>>N; long long int x,sum=0; std::vector<long long int> v; for(int i=0;i<N;i++) { cin>>x; v.push_back(x); } /*vector<long long int>::iterator itr; itr = v.begin(); for(itr=v.begin();itr<v.end();itr++) sum += *itr;*/ sum = accumulate(v.begin(),v.end(),0); cout<<sum; return 0; } My program is returning abstract value using accumulate, but if I use the for loop, the answer is