Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #define N 10
- using namespace std;
- struct Three {
- float sum_otr;
- float kol;
- float sum_pol;
- void printThree(){
- cout << "sum_otr = " << sum_otr <<" " << "kol = " << kol << " " << " sum_pol = " << sum_pol;
- }
- };
- struct Array {
- float *x;
- void vvod(int n) {
- x = new float[n];
- for (int i = 0; i < n; i++) {
- cout << "[" << i << "] = ";
- cin >> x[i];
- }
- }
- Three fukaz(Array * y) {
- Three z;
- z.sum_otr = 0;
- z.kol = 0;
- z.sum_pol = 0;
- for (int i = 0; i < N; i++)
- if (y->x[i] < 0)
- z.sum_otr = z.sum_otr + y->x[i];
- else
- if (y->x[i] > 0)
- z.sum_pol = z.sum_pol + y->x[i];
- else
- z.kol++;
- z.printThree();
- }
- Three fssilka(Array & y) {
- Three c;
- c.sum_otr = c.kol = c.sum_pol = 0;
- for (int i = 0; i < N; i++)
- if (y.x[i] < 0)
- c.sum_otr = c.sum_otr + y.x[i];
- else
- if (y.x[i] > 0)
- c.sum_pol = c.sum_pol + y.x[i];
- else
- c.kol++;
- c.printThree();
- }
- };
- int main ()
- {
- Array x;
- x.fukaz (&x);
- x.fssilka (x);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement