Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <iomanip>
- #include <stdlib.h>
- using namespace std;
- int main()
- {
- setlocale(LC_ALL, "RUS");
- int n, k, r2;
- float x, y, r1;
- char str[256], sl[10], oper1, oper2;
- fstream input;
- ofstream output;
- input.open("H:\\input.txt", ios::in);
- output.open("H:\\output.txt", ios::out);
- if (input)
- {
- while (!input.eof())
- {
- input.getline(str, 256);
- cout << str << endl;
- }
- input.close();
- input.open("H:\\input.txt", ios::in);
- for (int i = 0; i <= 16; i++)
- {
- input >> sl;
- switch (i)
- {
- case 5: x = atoi(sl);
- case 6: oper1 = sl[0];
- case 7: y = atoi(sl);
- case 14: n = atoi(sl);
- case 15: oper2 = sl[0];;
- case 16: k = atoi(sl);
- }
- }
- if (oper1 == '/') r1 = x / y;
- else
- {
- if (oper1 == '-') r1 = x - y;
- else
- {
- if (oper1 == '*') r1 = x*y;
- else r1 = x + y;
- }
- }
- if (oper2 == '+') r2 = n + k;
- else
- {
- if (oper2 == '-') r2 = n - k;
- else
- {
- if (oper2 == '+') r2 = n + k;
- else r2 = n*k;
- }
- }
- output << x << " " << oper1 << " " << y << " = " << r1 << endl;
- output << n << " " << oper2 << " " << k << " = " << r2 << endl;
- input.close();
- output.close();
- }
- else cout << "” ©« Ґ ¬®¦Ґв Ўлвм ®вЄалв!" << endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement