Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. #include <stdlib.h>
  4. #include <iomanip>
  5.  
  6. using namespace std;
  7.  
  8. struct spisok
  9. {
  10. float x;
  11. float y;
  12. float z;
  13. };
  14.  
  15. void GetData(spisok *m, int n)
  16. {
  17. cin.ignore();
  18. for (int i = 0; i<n; i++)
  19. {
  20. cout << "\n";
  21. cout << "x" << i + 1 << " :";
  22. cin>> setw(6) >> (m[i].x);
  23.  
  24. cout << "y" << i + 1 << " :";
  25. cin >> setw(6) >> (m[i].y);
  26.  
  27. cout << "z" << i + 1 << " :";
  28. cin >> setw(6) >> (m[i].z);
  29. }
  30. }
  31.  
  32. void ShowData(spisok *m, int n)
  33. {
  34. for (int i = 0; i<n; i++)
  35. {
  36. cout << m[i].x << " " << m[i].y << " " << m[i].z << endl;
  37. }
  38. }
  39.  
  40. void ShowDataZero(spisok *m, int n, int t, int s)
  41. {
  42.  
  43. for (int i = 0; i<n; i++)
  44. {
  45. if (m[i].x > 0 || m[i].x == 0)
  46. s++;
  47. if (m[i].y > 0 || m[i].y == 0)
  48. s++;
  49. if (m[i].z > 0 || m[i].z == 0)
  50. s++;
  51. if (t == s)
  52. cout << m[i].x << " " << m[i].y << " " << m[i].z << endl;
  53. }
  54. }
  55.  
  56. spisok *m;
  57. int n;
  58. int t;
  59. int s;
  60.  
  61.  
  62. int main()
  63. {
  64. cout << "vvedi kolichestvo elementov spiska: " << endl;
  65. cin >> n;
  66. m = new spisok[n];
  67. GetData(m, n);
  68. ShowData(m, n);
  69. s = 0;
  70. cout << "kolichestvo polojitelnih elementov: " << endl;
  71. cin >> t;
  72. ShowDataZero(m, n, t, s);
  73. system("pause");
  74. return 0;
  75. delete[]m;
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement