Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #include<iostream>
- #include<iomanip>
- #include<string>
- using namespace std;
- class Array
- {
- friend ostream &operator<<(ostream&, const Array&);
- friend istream &operator>>(istream&, Array&);
- public:
- Array(int * = 0, int * = 0, int * = 0);
- Array &operator+(const Array&rhs)const
- {
- return Array();
- }
- Array &operator-(const Array&rhs)const
- {
- return Array();
- }
- bool operator>(const Array&rhs)const
- {
- return avg1 > rhs.avg2;
- }
- bool operator<=(const Array&rhs)const
- {
- return avg1 <= rhs.avg2;
- }
- Array &operator--(); //preincrement
- Array &operator--(int); // postincrement
- private:
- int a1[10], a2[10], a3[10];
- float avg1, avg2;
- };
- Array::Array(int a[10], int b[10], int c[10])
- {
- for (int i = 1; i <= 10; i++)
- {
- a1[i] = a[i];
- a2[i] = b[i];
- a3[i] = c[i];
- }
- }
- ostream &operator<<(ostream &output, const Array &a)
- {
- for (int i = 1; i <= 10; i++)
- {
- output << a.a1[i] << ' ';
- }
- for (int i = 1; i <= 10; i++)
- {
- output << a.a2[i] << ' ';
- }
- return output;
- }
- istream &operator>>(istream &input, Array &a)
- {
- for (int i = 1; i <= 10; i++)
- {
- input >> a.a1[i];
- }
- for (int i = 1; i <= 10; i++)
- {
- input >> a.a2[i];
- }
- return input;
- }
- int main()
- {
- Array a, b, sum, diff;
- cout << "Enter data for first array: ";
- cin >> a;
- cout << "Enter data for second array: ";
- cin >> b;
- sum = a + b;
- diff = a - b;
- cout << "First array: " << a << endl << endl;
- cout << "Second array: " << b << endl << endl;
- cout << "Sum: " << sum << endl << endl;
- cout << "Difference: " << diff << endl << endl;
- if (a > b)
- cout << "First average without highest & lowest values, is bigger" << endl;
- if (a <= b)
- cout << "First average without highest & lowest values, is smaller or equal to" << endl << endl;
- cout << "Predecrement: " << --a << endl;
- cout << "Postdecrement: " << a-- << endl;
- cout << "After Postdecrement: " << a << endl;
- system("PAUSE");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement