Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int a, b, n, temp1 = 0, temp1a = 0, temp2 = 0, temp2a = 0, temp2b = 1, temp3 = 1, temp3a = 1;
- char jakieDzialanie;
- cin >> n;
- for(int i = 0; i < n; i++)
- {
- temp1a = 0, temp2a = 0, temp3a = 1, a = 0, b = 0, jakieDzialanie = 0;
- cin >> a;
- cin >> b;
- cin >> jakieDzialanie;
- switch(jakieDzialanie)
- {
- case '+':
- if (a == b)
- {
- return 0;
- }
- if (b > a)
- {
- temp1 = b - a;
- for (int i = 0; i <= temp1; i++)
- {
- temp1a = temp1a + a;
- a = a + 1;
- }
- }
- else if (b < a)
- {
- temp1 = a - b;
- for (int i = 0; i <= temp1; i++)
- {
- temp1a = temp1a + b;
- b = b + 1;
- }
- }
- cout << temp1a << endl;
- break;
- case '-':
- if (a == b)
- {
- return 0;
- }
- if (b < a)
- {
- temp2 = (b - a);
- if (temp2 < 0)
- {
- temp2 = (temp2*(-1));
- }
- for (int i = 0; i <= temp2; i++)
- {
- temp2a = temp2a - a;
- a = a - 1;
- }
- }
- else if (b > a)
- {
- temp2 = (a - b);
- if (temp2 < 0)
- {
- temp2 = (temp2*(-1));
- }
- for (int i = 0; i <= temp2; i++)
- {
- temp2a = temp2a - b;
- b = b - 1;
- }
- }
- cout << temp2a << endl;
- break;
- case '*':
- if (a == b)
- {
- return 0;
- }
- if (b > a)
- {
- temp3 = b - a;
- for (int i = 0; i <= temp3; i++)
- {
- temp3a = temp3a * a;
- a = a + 1;
- }
- }
- else if (b < a)
- {
- temp3 = a - b;
- for (int i = 0; i <= temp3; i++)
- {
- temp3a = temp3a * b;
- b = b + 1;
- }
- }
- cout << temp3a << endl;
- break;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement