frustration

решить систему с шагом. 2,28

Feb 22nd, 2019
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.51 KB | None | 0 0
  1. /*  задание 2.28
  2.     решить систему с шагом
  3.     | (tan(x) + 5) / cos(x), x < 1
  4. y = < sin(x) / (sqrt(cos(x)) + 1), (x >= 2) && (x <= 3)
  5.     | (sin(x) / cos(x)) / (sqrt(x + 3)), x > 7
  6. */
  7.  
  8. #include <iostream>
  9. #include <conio.h>
  10. #include <stdio.h>
  11. #include <cmath>
  12. #include <iomanip>
  13.  
  14.  
  15.  
  16. using namespace std;
  17.  
  18.  
  19. int main(){
  20.     float r, Xnach, Xkon, Xd;
  21.     bool flag1=false;
  22.     bool flag2 = false;
  23.    
  24.     cout << "vvod Xnach=";
  25.     cin >> Xnach;
  26.     cout << "vvod Xkon=";
  27.     cin >> Xkon;
  28.     cout << "vvod Xd=";
  29.     cin >> Xd;
  30.     cout << "______________________" << endl;
  31.     cout << "|   X   |      F     |" << endl;
  32.     cout << "|_______|____________|" << endl;
  33.  
  34.    
  35.     for (float x = Xnach; x <= Xkon; x += Xd){
  36.  
  37.         if (x < 1){
  38.             if (cos(x) != 0)
  39.                 r = (tan(x) + 5) / cos(x);
  40.         }
  41.         else if (x < 2)
  42.             flag1 = true;
  43.  
  44.  
  45.  
  46.         else if (x >= 2 && x <= 3){
  47.             flag1 = false;
  48.                 if (cos(x) >= 0 && sqrt(cos(x)) + 1 != 0)
  49.                 r = sin(x) / (sqrt(cos(x)) + 1);
  50.                 else flag2 = true;
  51.         }
  52.         else if (x <= 7){
  53.             flag1 = true;
  54.             flag2 = false;
  55.         }
  56.  
  57.  
  58.         else if (x > 7){
  59.             flag1 = false;
  60.             if ((sqrt(x + 3)) != 0)
  61.                     r = (sin(x) / cos(x)) / (sqrt(x + 3));
  62.             else flag2 = true;
  63.             }
  64.  
  65.  
  66.             else continue;
  67.  
  68.  
  69.             cout.width(10);
  70.  
  71.             if (flag1)
  72.             printf_s("|%5.1f  | ne zadano  |\n", x);
  73.             else if (flag2)
  74.                 printf_s("|%5.1f  |net rechenii|\n", x);
  75.             else printf_s("|%5.1f  |  %6.1f    |\n", x, r);
  76.             cout << "|_______|____________|" << endl;
  77.  
  78.  
  79.         }
  80.      
  81.  
  82.    
  83.  
  84.     _getch();
  85.     return 0;
  86.    
  87. }
Add Comment
Please, Sign In to add comment