Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- #include <stdlib.h>
- #include <iomanip>
- using namespace std;
- struct spisok
- {
- float x;
- float y;
- float z;
- };
- void GetData(spisok *m, int n)
- {
- cin.ignore();
- for (int i = 0; i<n; i++)
- {
- cout << "\n";
- cout << "x" << i + 1 << " :";
- cin>> setw(6) >> (m[i].x);
- cout << "y" << i + 1 << " :";
- cin >> setw(6) >> (m[i].y);
- cout << "z" << i + 1 << " :";
- cin >> setw(6) >> (m[i].z);
- }
- }
- void ShowData(spisok *m, int n)
- {
- for (int i = 0; i<n; i++)
- {
- cout << m[i].x << " " << m[i].y << " " << m[i].z << endl;
- }
- }
- void ShowDataZero(spisok *m, int n, int t, int s)
- {
- for (int i = 0; i<n; i++)
- {
- if (m[i].x > 0 || m[i].x == 0)
- s++;
- if (m[i].y > 0 || m[i].y == 0)
- s++;
- if (m[i].z > 0 || m[i].z == 0)
- s++;
- if (t == s)
- cout << m[i].x << " " << m[i].y << " " << m[i].z << endl;
- }
- }
- spisok *m;
- int n;
- int t;
- int s;
- int main()
- {
- cout << "vvedi kolichestvo elementov spiska: " << endl;
- cin >> n;
- m = new spisok[n];
- GetData(m, n);
- ShowData(m, n);
- s = 0;
- cout << "kolichestvo polojitelnih elementov: " << endl;
- cin >> t;
- ShowDataZero(m, n, t, s);
- system("pause");
- return 0;
- delete[]m;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement