Advertisement
Alysik

Untitled

Oct 20th, 2019
134
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. #define N 10
  3. using namespace std;
  4. struct Three {
  5.     float sum_otr;
  6.     float kol;
  7.     float sum_pol;
  8.     void printThree(){
  9.         cout << "sum_otr = " << sum_otr <<" " << "kol = " << kol << " " << " sum_pol = " << sum_pol;
  10.     }
  11. };
  12. struct Array {
  13.     float *x;
  14.     void vvod(int n) {
  15.         x = new float[n];
  16.         for (int i = 0; i < n; i++) {
  17.             cout << "[" << i << "] = ";
  18.             cin >> x[i];
  19.         }
  20.     }
  21.     Three fukaz(Array * y) {
  22.         Three z;
  23.         z.sum_otr = 0;
  24.         z.kol = 0;
  25.         z.sum_pol = 0;
  26.         for (int i = 0; i < N; i++)
  27.             if (y->x[i] < 0)
  28.                 z.sum_otr = z.sum_otr + y->x[i];
  29.             else
  30.                 if (y->x[i] > 0)
  31.                     z.sum_pol = z.sum_pol + y->x[i];
  32.                 else
  33.                     z.kol++;
  34.         z.printThree();
  35.     }
  36.  
  37.     Three fssilka(Array & y) {
  38.         Three c;
  39.         c.sum_otr = c.kol = c.sum_pol = 0;
  40.         for (int i = 0; i < N; i++)
  41.             if (y.x[i] < 0)
  42.                 c.sum_otr = c.sum_otr + y.x[i];
  43.             else
  44.                 if (y.x[i] > 0)
  45.                     c.sum_pol = c.sum_pol + y.x[i];
  46.                 else
  47.                     c.kol++;
  48.         c.printThree();
  49.     }
  50. };
  51.  
  52. int main ()
  53. {
  54.     Array x;
  55.     x.fukaz (&x);
  56.     x.fssilka (x);
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement