Advertisement
Dennnhhhickk

Untitled

Dec 29th, 2017
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. char ch;
  2. ll a, b, ans = 0, ans1 = 0;
  3. cin >> ch >> a >> b;
  4. if (ch != '+')
  5. ans = 1, ans1 = 1;
  6. while (a)
  7. {
  8. if (ch == '+')
  9. ans += a % 10;
  10. else
  11. ans *= a % 10;
  12. a /= 10;
  13. }
  14. while (b)
  15. {
  16. if (ch == '+')
  17. ans1 += b % 10;
  18. else
  19. ans1 *= b % 10;
  20. b /= 10;
  21. }
  22. if (ch == '+')
  23. cout << ans + ans1;
  24. else
  25. cout << ans * ans1;
  26. cout << endl;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement