Username77177

Dahl-Programming-Lab4P3-16

Oct 9th, 2019
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.80 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     double y[12];
  8.     double a = 2.2, b = 0.3, deltai = 0.5, i = 1; // i [1;6]
  9.     int index = 0;
  10.     do
  11.     {
  12.         //Ariphmetic
  13.         if (i < 4)
  14.         {
  15.             y[index] = a * pow(i, 2) + b * i;
  16.         }
  17.         else if (i == 4)
  18.         {
  19.             y[index] = pow(i, 2) + 0.5 * i;
  20.         }
  21.         else
  22.         {
  23.             y[index] = sqrt(abs(a * i + i));
  24.         }
  25.         ++index;
  26.         i += 0.5;
  27.     }while (i <= 6);
  28.  
  29.  
  30.     index = 0;
  31.     i = 1;
  32.     while (true) //Если умею, то почему бы и нет?
  33.     {
  34.         cout << "i = " << i << "\t y = " << y[index] << endl;
  35.         i += 0.5;
  36.         index++;
  37.         if (i > 6)
  38.         {
  39.             break;
  40.         }
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment