fork download
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7. double a = 1.0;
  8. double b = 3.0;
  9. int n = 5;
  10.  
  11. double dx = (b - a) / n;
  12. double x = a;
  13. double s = 0.0;
  14.  
  15. for (int i = 1; i <= n; i++) {
  16. s += dx * sin(x);
  17. x += dx;
  18. }
  19.  
  20. cout << "Przyblizona wartosc pola (metoda prostokatow): " << s << endl;
  21.  
  22. return 0;
  23. }
  24.  
Success #stdin #stdout 0.01s 5312KB
stdin
Standard input is empty
stdout
Przyblizona wartosc pola (metoda prostokatow): 1.64991