Advertisement
Guest User

Untitled

a guest
Nov 19th, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.01 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include<iostream>
  3. #include<iomanip>
  4. #include<string>
  5. using namespace std;
  6.  
  7. class Array
  8. {
  9. friend ostream &operator<<(ostream&, const Array&);
  10. friend istream &operator>>(istream&, Array&);
  11. public:
  12. Array(int * = 0, int * = 0, int * = 0);
  13.  
  14. Array &operator+(const Array&rhs)const
  15. {
  16. return Array();
  17. }
  18.  
  19. Array &operator-(const Array&rhs)const
  20. {
  21. return Array();
  22. }
  23.  
  24. bool operator>(const Array&rhs)const
  25. {
  26. return avg1 > rhs.avg2;
  27. }
  28.  
  29. bool operator<=(const Array&rhs)const
  30. {
  31. return avg1 <= rhs.avg2;
  32. }
  33.  
  34. Array &operator--(); //preincrement
  35. Array &operator--(int); // postincrement
  36.  
  37. private:
  38. int a1[10], a2[10], a3[10];
  39. float avg1, avg2;
  40. };
  41.  
  42. Array::Array(int a[10], int b[10], int c[10])
  43. {
  44. for (int i = 1; i <= 10; i++)
  45. {
  46. a1[i] = a[i];
  47. a2[i] = b[i];
  48. a3[i] = c[i];
  49. }
  50. }
  51.  
  52. ostream &operator<<(ostream &output, const Array &a)
  53. {
  54. for (int i = 1; i <= 10; i++)
  55. {
  56. output << a.a1[i] << ' ';
  57. }
  58.  
  59. for (int i = 1; i <= 10; i++)
  60. {
  61. output << a.a2[i] << ' ';
  62. }
  63. return output;
  64. }
  65.  
  66. istream &operator>>(istream &input, Array &a)
  67. {
  68. for (int i = 1; i <= 10; i++)
  69. {
  70. input >> a.a1[i];
  71. }
  72.  
  73. for (int i = 1; i <= 10; i++)
  74. {
  75. input >> a.a2[i];
  76. }
  77. return input;
  78. }
  79.  
  80. int main()
  81. {
  82. Array a, b, sum, diff;
  83. cout << "Enter data for first array: ";
  84. cin >> a;
  85. cout << "Enter data for second array: ";
  86. cin >> b;
  87. sum = a + b;
  88. diff = a - b;
  89. cout << "First array: " << a << endl << endl;
  90. cout << "Second array: " << b << endl << endl;
  91. cout << "Sum: " << sum << endl << endl;
  92. cout << "Difference: " << diff << endl << endl;
  93. if (a > b)
  94. cout << "First average without highest & lowest values, is bigger" << endl;
  95. if (a <= b)
  96. cout << "First average without highest & lowest values, is smaller or equal to" << endl << endl;
  97. cout << "Predecrement: " << --a << endl;
  98. cout << "Postdecrement: " << a-- << endl;
  99. cout << "After Postdecrement: " << a << endl;
  100. system("PAUSE");
  101. return 0;
  102. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement