Advertisement
Guest User

solution4and3

a guest
Oct 15th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.73 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. class solution4
  4. {
  5.     double a = 1.65;
  6.     double h = 0.1;
  7.    
  8.     double case1(double xx)
  9.     {
  10.         return -3*xx*xx;
  11.     }
  12.     double case2(double xx)
  13.     {
  14.         return a * xx + 4 * sqrt(xx);
  15.     }
  16.     double case3(double xx)
  17.     {
  18.         return log(xx+4)*sqrt(xx+a);
  19.     }
  20.     public:
  21.     void cMain()
  22.     {
  23.        
  24.         double y;
  25.         for(double x = 0.1; x < 2.1 ; x = x + h)
  26.         {
  27.             if(x<1.4) y = case1(x);
  28.            
  29.             else if(x==1.4) y = case2(x);
  30.            
  31.             else if(x>1.4) y = case3(x);
  32.            
  33.             cout << x << " " << y << endl;//OUTPUT ozunuz deyisin uygun formaya
  34.         }
  35.     }
  36. };
  37. //*************************************************************************
  38. class solution3
  39. {
  40.     double a = 2.8;
  41.     double h = 0.05;
  42.     double b = 0.3;
  43.    
  44.     double case1(double xx)//x>1.3
  45.     {
  46.         return a * xx * xx + b * xx + a;
  47.     }
  48.     double case2(double xx)//x<1.2
  49.     {
  50.         return a / xx + sqrt(xx * xx + 1);
  51.     }
  52.     double case3(double xx)//1.2<=x<1.3
  53.     {
  54.         return (a + b * xx) * sqrt(xx * xx + 1);
  55.     }
  56.     public:
  57.     void cMain()
  58.     {
  59.        
  60.         double y;
  61.         for(double x = 1; x <= 2.05 ; x = x + h)
  62.         {
  63.             if(x>1.3) y = case1(x);
  64.            
  65.             else if(x<1.2) y = case2(x);
  66.            
  67.             else if(x>=1.2 && x<=1.3) y = case3(x);
  68.            
  69.             cout << x << " " << y << endl;//OUTPUT ozunuz deyisin uygun formaya
  70.         }
  71.     }
  72. };
  73. //*************************************************************
  74. int main() {
  75.    // solution4 a;
  76.     //a.cMain();
  77.     solution3 b;
  78.     b.cMain();
  79.     return 0;
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement