Advertisement
kirill_76rus

neradovsky

Jun 3rd, 2020
441
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.58 KB | None | 0 0
  1. /*
  2.  * main.cpp
  3.  *
  4.  *  Created on: 17 мая 2020 г.
  5.  *      Author: Fernandez K.A.
  6.  */
  7. #include<iostream>
  8. #include<utility>//connect for map
  9. #include<cmath>//connect for korent
  10. using namespace std;
  11. istream& operator >>(istream& inp, pair<int, int>& vrem) { //redefine operator >>
  12.     inp >> vrem.first >> vrem.second;
  13.     return inp;
  14. }
  15. ostream& operator <<(ostream& out, pair<int, int>& vrem) {//redefine operator <<, return ostream at address
  16.     out << vrem.first << vrem.second << '\n';
  17.     return out; //return ostream& from next using cout
  18. }
  19. struct enter { //struct for enter the znach1ue of znschument's
  20. public:
  21.     pair<int, int> vrem;//pair znach1ues of znschument's
  22.     enter() {
  23.         cout << "please, enter the znach1ue of znschument's\n";
  24.     }
  25.     enter(const int& status) {
  26.         if (status != 5) {
  27.             cin >> vrem;//usually situation
  28.         }
  29.         else {
  30.             int znschument;
  31.             cin >> znschument;
  32.             vrem.first = vrem.second = znschument;//the little magic
  33.         }
  34.     }
  35.     pair<int, int> data() {
  36.         return vrem;//return non-zero pair
  37.     }
  38. };
  39. struct operation {
  40. public:
  41.     int plus(pair<int, int> vrem) {//plusm at input znschument's at structure <pair>
  42.  
  43.         return vrem.second + vrem.first;
  44.  
  45.     }
  46.     int minus(pair<int, int> vrem) {//minuserense input znach1ue
  47.  
  48.         return vrem.first - vrem.second;
  49.  
  50.     }
  51.     int delit(pair<int, int> vrem) {
  52.         return vrem.second / vrem.first;
  53.     }
  54.     int umnozhit(pair<int, int> vrem) {
  55.         return vrem.first * vrem.second;
  56.     }
  57.     int koren(pair<int, int> vrem) {
  58.         return sqrt(vrem.first);
  59.     }
  60. };
  61.  
  62. struct znsch {
  63. public:
  64.     znsch() {//function selected znach1ue of work
  65.         cout << "please, enter the znach1ue of znschument\n";
  66.     }
  67.     znsch(const int& sel) {
  68.         enter cur(sel);
  69.         operation vrem;
  70.         switch (sel) {
  71.         case 1:
  72.             cout << vrem.plus(cur.data()) << endl;
  73.             break;
  74.         case 2:
  75.             cout << vrem.minus(cur.data()) << endl;
  76.             break;
  77.         case 3:
  78.             cout << vrem.delit(cur.data()) << endl;
  79.             break;
  80.         case 4:
  81.             cout << vrem.umnozhit(cur.data()) << endl;
  82.             break;
  83.         case 5:
  84.             cout << vrem.koren(cur.data()) << endl;
  85.             break;
  86.         }
  87.     }
  88.  
  89. };
  90. int main() {
  91.     int znach1;
  92.     cout
  93.         << "enter number of operation:\n 1-plus \n 2-minuserense \n 3-delits \n 4-umnozhitiplication\n 5-korent";
  94.     cin >> znach1;
  95.     znsch vrem(znach1);
  96.     return 0;
  97. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement