fork download
  1. #include <iostream>
  2. #include <cmath>
  3. int main()
  4. {
  5. double x1 = 1;
  6. double x2 = 10;
  7. double ret = 0;
  8.  
  9. for(double i = x1 - 1; i <= x2; ++i)
  10. {
  11. ret += (std::pow(x2,2)/2 + x2*i) - (std::pow(x1,2)/2 + i);
  12. std::cout<<ret<<"\n";
  13. }
  14. }
Success #stdin #stdout 0s 2852KB
stdin
Standard input is empty
stdout
49.5
108
175.5
252
337.5
432
535.5
648
769.5
900
1039.5