fork(9) download
  1. #include<bits/stdc++.h>
  2.  
  3. int GCD(int x, int y){
  4. return std::__gcd(x,y);
  5. }
  6.  
  7. int main() {
  8.  
  9. std::vector<int> v{10, 2, 4, 6};
  10.  
  11. std::cout<<"The sum of elements of v is : "<<accumulate(v.begin(), v.end(),0)<<" and GCD of all elements is : "<<accumulate(v.begin(), v.end(),0,GCD)<<std::endl;
  12. }
Success #stdin #stdout 0s 4476KB
stdin
Standard input is empty
stdout
The sum of elements of v is : 22 and GCD of all elements is : 2