Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- char ch;
- ll a, b, ans = 0, ans1 = 0;
- cin >> ch >> a >> b;
- if (ch != '+')
- ans = 1, ans1 = 1;
- while (a)
- {
- if (ch == '+')
- ans += a % 10;
- else
- ans *= a % 10;
- a /= 10;
- }
- while (b)
- {
- if (ch == '+')
- ans1 += b % 10;
- else
- ans1 *= b % 10;
- b /= 10;
- }
- if (ch == '+')
- cout << ans + ans1;
- else
- cout << ans * ans1;
- cout << endl;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement