Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- double RegCikl(double a, double b, double h, double& count) {
- double x, y;
- double Sum = 0;
- int n = ceil((b-a)/h)+1;
- for (int i = 1; i <= n; ++i) {
- x = a+(i-1)*h;
- y = exp(3*x) - cos(x*x);
- if(y < 0.0){
- Sum += y;
- count++;
- }
- }
- return Sum;
- }
- int main()
- {
- double a,b,h, count = 0;
- cin >> a >> b >> h;
- double Sum = RegCikl(a,b,h, count);
- cout << Sum << " " << count;
- return 0;
- }
Add Comment
Please, Sign In to add comment