0

I'm having a problem with this seemingly simple problem

This is on Codeforces. I know that this is prob not the right place to ask but i couldn't think of anywhere else. Here's the problem: Given a mathematical expression. The expression will be one of the following expressions: A+B A−B A∗B A/B Print the result of the mathematical expression. Input Only one line contains A,S and B (1≤A,B≤10^4) S is either (+,−,∗,/) . Output Print the result of the mathematical expression. The problem is that the test cases have no spaces. So I can't figure out a way to get A S and B. i tried cin.get() but apaprently that only works with char bc thats what i figured out from the complimation error messages can someone help me? thanks

14th May 2023, 9:04 PM
dragonerl
3 Respuestas
+ 2
Oof, what a hard problem. Probably the three numbers in input are of just 1 ciphre and joint together??
14th May 2023, 9:07 PM
Ugulberto Sánchez
Ugulberto Sánchez - avatar
+ 2
Save your tryout code as new SoloLearn code bit, then share its link in post Description. Your chances for answers improves once you show that you have given an effort in trying. And please, add C++ in your post tags for language wise context clarity ...
14th May 2023, 9:16 PM
Ipang
0
This should be trivial with scanf, which you should learn to use anyway since get is vulnerable to malicious input. This particular case should even be easy to sanitize if those numbers are guaranteed to be ints, 'cause then you only need to check %5d (I'd have to think about how many digits you'd need for a float). After that, using the %c with switch pretty much writes itself.
14th May 2023, 10:17 PM
Orin Cook
Orin Cook - avatar