Question: You are given 4 numbers ( 1 - 9 ) randomly, you need to find a way to calculate them as 2 4 by applying

You are given 4 numbers (1-9) randomly, you need to find a way to calculate them as 24 by applying numberic operations ( add, minus, divide and multiply). Every number can only be used one time.
For example,4,3,2,9, you can do9/3*4*2=24.
Another example,4,3,3,1, you can do (3-1)*3*4=24.
One more example, 4,3,3,2, there is no way to make 24, you just report "No Way".
Write a program to get 4 numbers from user input, then report how to calculate 24, or say "No Way".

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!