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