Advertisement
Kentoo

E#2

Jan 16th, 2018
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.69 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. #include <iomanip>
  4. #include <cmath>
  5.  
  6. using namespace std;
  7.  
  8. void main()
  9. {
  10.     const int N = 15;
  11.     int x[N] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
  12.     double y[N], ysum = 0;
  13.     int xmin = INT32_MAX;
  14.     cout << "{x} = ";
  15.     for (int i = 0; i < N; i++) {
  16.         if (x[i] < xmin)
  17.             xmin = x[i];
  18.         cout << x[i] << " ";
  19.     }
  20.     cout << endl;
  21.     if (xmin != 0) {
  22.         cout << "{y} = ";
  23.         for (int i = 0; i < N; i++) {
  24.             y[i] = pow(x[i], 3) / (xmin * 1.0);
  25.             cout << y[i] << " ";
  26.             ysum += y[i];
  27.         }
  28.         cout << endl << "sum of odd {y} by indexes = " << ysum << endl;
  29.     }
  30.     else {
  31.         cout << "Series {y} is equal to inf" << endl;
  32.     }
  33.     system("pause");
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement