0

add,subtract multilication,and divison to compete for gefemony

input: enter two non-zero integers output: output all the expression with the lagrest operation result. if there are multiple expressions with the largest result,one expression is output per line,and output is performed line by line according to the priority order of "addition,subtraction ,multiplication and division" for example: input 2,2 ouput 2+2=4 2*2=4 and my attempt is that i define a = x + y, B = x - y, C = x * y, d = x / y, how to output expressions after comparing the sizes of a, b, c, d

10th Dec 2018, 3:29 AM
ljf5154
8 Réponses
+ 11
Show us your attempt so we may help you!!
10th Dec 2018, 3:32 AM
Hannah Grace
Hannah Grace - avatar
+ 4
Hey ljf5154 ! As said by Hannah Grace and Gordon , please only use this section if you have a specific question about coding, rather than just giving instructions for a code. I would recommend trying to solve the problem yourself, while asking any specific questions if you get stuck on something. https://www.sololearn.com/discuss/1316935/?ref=app https://www.sololearn.com/discuss/333866/?ref=app
10th Dec 2018, 3:33 AM
Faisal
Faisal - avatar
+ 3
This is not homework answer providing platform You need to show your code attempt If you are stuck, we give you hints
10th Dec 2018, 3:32 AM
Gordon
Gordon - avatar
+ 1
It seems that we think too much. Our teacher's request is as long as X is in front. https://code.sololearn.com/c4UUDthcmW6f/?ref=app
12th Dec 2018, 1:39 PM
ljf5154
+ 1
Hilarious 😂 It's still a good practice of if else statements, isn't it? For subtraction, you can use the absolute value, which turns negative numbers to positive. Example: abs(1-2)=abs(-1)=+1 so, abs(x-y) will give you the larger subtraction result. For division, you can define a function for the maximum value, which returns largest numbers. Example: max(-100,1/8,1)=1 So, max(x/y, y/x) will give you the larger division result.
12th Dec 2018, 2:27 PM
Gordon
Gordon - avatar
0
sorry.and i define a = x + y, B = x - y, C = x * y, d = x / y, how to output expressions after comparing the sizes of a, b, c, d
10th Dec 2018, 4:03 AM
ljf5154
0
The last requirement is the priority. So must be in order a, b, c, d. For largest output, actually this description does not make sense to me. But if I must provide a guess, it means, e. g. 2-6=-4,6-2=4,so you take 6-2 in b This way, you use absolute method or max method for minus For division, you use max method on x/Y and y/x A, c not problem because commutative. Do you understand what I mean above? Can you type in code playground and post link to your code to here?
10th Dec 2018, 4:10 AM
Gordon
Gordon - avatar
0
Of course, before my classmates reminded me, my complicated practice was this. I was tired. I was just a novice. https://code.sololearn.com/c441lCz5hhO8/?ref=app
12th Dec 2018, 2:00 PM
ljf5154