Advertisement
Elfik

2006 Figura

Mar 9th, 2018
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.04 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. double f(double x) {
  6.     return x*x/50;
  7. }
  8.  
  9. double g(double x) {
  10.     return 1+x*x/100-x/200;
  11. }
  12.  
  13. double task_one() {
  14.     double surface = 0;
  15.     float step = 0.1;
  16.    
  17.     //nad OX
  18.     for (float i = 0; i < 10; i += step) {
  19.         double a = g(i);
  20.         double b = g(i+step);
  21.         surface += ((a+b)*step)/2;
  22.     }
  23.     //pod OY
  24.     for (float i = 0; i < 10; i += step) {
  25.         double a = f(i);
  26.         double b = f(i+step);
  27.         surface += ((a+b)*step)/2;
  28.     }
  29.     cout.precision(4);
  30.     return surface;
  31. }
  32.  
  33. double task_two() {
  34.    
  35.     int a = 26;
  36.     int b = 100;
  37.     double minX, maxX, minY, maxY;
  38.    
  39.     for (double i = 0; ; i++) {
  40.         if ((int)g(i) + (int)f(i) >= a) {
  41.             minX = i;
  42.             maxX = i + b;
  43.             maxY = (int)g(i);
  44.             minY = maxY - a;
  45.         break;
  46.         }
  47.     }
  48.     cout << "C- " << maxX << endl;
  49.     cout << "A: " << minX << " , " << maxY << endl;
  50.     cout << "B: " << minX << " , " << minY << endl;
  51.     cout << "C: " << maxX << " , " << maxY << endl;
  52.     cout << "D: " << maxX << " , " << minY << endl;
  53. }
  54.  
  55. int main() {
  56.     cout << task_one() << endl;
  57.     task_two();
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement