Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * main.cpp
- *
- * Created on: 17 мая 2020 г.
- * Author: Fernandez K.A.
- */
- #include<iostream>
- #include<utility>//connect for map
- #include<cmath>//connect for sqrt
- using namespace std;
- istream& operator >>(istream &inp, pair<int, int> &tmp) { //redefine operator >>
- inp >> tmp.first >> tmp.second;
- return inp;
- }
- ostream& operator <<(ostream &out, pair<int, int> &tmp) {
- out << tmp.first << tmp.second << '\n';
- return out; //return ostream& from next using cout
- }
- struct enter { //struct for enter the value of argument's
- public:
- pair<int, int> tmp;//pair values of argument's
- enter() {
- cout << "please, enter the value of argument's\n";
- }
- enter(const int &status) {
- if (status != 5) {
- cin >> tmp;//usually situation
- } else {
- int argument;
- cin >> argument;
- tmp.first = tmp.second = argument;//the little magic
- }
- }
- pair<int, int> data() {
- return tmp;//return non-zero pair
- }
- };
- struct operation {
- public:
- int sum(pair<int, int> tmp) {
- return tmp.second + tmp.first;
- }
- int diff(pair<int, int> tmp) {
- return tmp.first - tmp.second;
- }
- int division(pair<int, int> tmp) {
- return tmp.second / tmp.first;
- }
- int mult(pair<int, int> tmp) {
- return tmp.first * tmp.second;
- }
- int sqr(pair<int, int> tmp) {
- return sqrt(tmp.first);
- }
- };
- struct arg {
- public:
- arg() {
- cout << "please, enter the value of argument\n";
- }
- arg(const int &sel) {
- enter cur(sel);
- operation tmp;
- switch (sel) {
- case 1:
- cout << tmp.sum(cur.data()) << endl;
- break;
- case 2:
- cout << tmp.diff(cur.data()) << endl;
- break;
- case 3:
- cout << tmp.division(cur.data()) << endl;
- break;
- case 4:
- cout << tmp.mult(cur.data()) << endl;
- break;
- case 5:
- cout << tmp.sqr(cur.data()) << endl;
- break;
- }
- }
- };
- int main() {
- int val;
- cout
- << "enter number of operation:\n 1-sum \n 2-differense \n 3-divisions \n 4-multiplication\n 5-sqrt";
- cin >> val;
- arg tmp(val);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment