Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<cmath>
- using namespace std;
- double finder(double a, double b, double h1, double c, double d, double h2, double& count){
- int n1 = int((b + h1/2. - a)/h1) + 1;
- int n2 = int((d + h2/2. - c)/h2) + 1;
- count = 0;
- double sum = 0;
- double x, y, z;
- for(int i=1; i<n1; ++i){
- x = a + (i-1) * h1;
- for(int j=1; j<n2; ++j){
- y = c + (j-1) * h2;
- z = y - (0.1*sin(x)/2);
- if(z < 0){
- count++;
- sum+=z;
- }
- }
- }
- return sum;
- }
- int main(){
- double a, b, h1, c, d, h2, count, sum;
- cin >> a >> b >> h1 >> c >> d >> h2;
- sum = finder(a, b, h1, c, d, h2, count);
- cout << sum << endl << count;
- }
Add Comment
Please, Sign In to add comment