Advertisement
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 korent
- using namespace std;
- istream& operator >>(istream& inp, pair<int, int>& vrem) { //redefine operator >>
- inp >> vrem.first >> vrem.second;
- return inp;
- }
- ostream& operator <<(ostream& out, pair<int, int>& vrem) {//redefine operator <<, return ostream at address
- out << vrem.first << vrem.second << '\n';
- return out; //return ostream& from next using cout
- }
- struct enter { //struct for enter the znach1ue of znschument's
- public:
- pair<int, int> vrem;//pair znach1ues of znschument's
- enter() {
- cout << "please, enter the znach1ue of znschument's\n";
- }
- enter(const int& status) {
- if (status != 5) {
- cin >> vrem;//usually situation
- }
- else {
- int znschument;
- cin >> znschument;
- vrem.first = vrem.second = znschument;//the little magic
- }
- }
- pair<int, int> data() {
- return vrem;//return non-zero pair
- }
- };
- struct operation {
- public:
- int plus(pair<int, int> vrem) {//plusm at input znschument's at structure <pair>
- return vrem.second + vrem.first;
- }
- int minus(pair<int, int> vrem) {//minuserense input znach1ue
- return vrem.first - vrem.second;
- }
- int delit(pair<int, int> vrem) {
- return vrem.second / vrem.first;
- }
- int umnozhit(pair<int, int> vrem) {
- return vrem.first * vrem.second;
- }
- int koren(pair<int, int> vrem) {
- return sqrt(vrem.first);
- }
- };
- struct znsch {
- public:
- znsch() {//function selected znach1ue of work
- cout << "please, enter the znach1ue of znschument\n";
- }
- znsch(const int& sel) {
- enter cur(sel);
- operation vrem;
- switch (sel) {
- case 1:
- cout << vrem.plus(cur.data()) << endl;
- break;
- case 2:
- cout << vrem.minus(cur.data()) << endl;
- break;
- case 3:
- cout << vrem.delit(cur.data()) << endl;
- break;
- case 4:
- cout << vrem.umnozhit(cur.data()) << endl;
- break;
- case 5:
- cout << vrem.koren(cur.data()) << endl;
- break;
- }
- }
- };
- int main() {
- int znach1;
- cout
- << "enter number of operation:\n 1-plus \n 2-minuserense \n 3-delits \n 4-umnozhitiplication\n 5-korent";
- cin >> znach1;
- znsch vrem(znach1);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement