- 3
Who can help me? This is my homework
Two-Input Function Calculator Function Behavior ADD a b a + b SUB a b a - b MUL a b a * b MAX a b (a>=b) ? a : b MIN a b (a<b) ? a : b EX1, “ADD MUL 2 3 4” is 2*3+4 = 10 EX2, “ADD 4 MUL 3 3” is 4+3*3 = 13 EX3, “ADD MUL 2 3 MUL 4 5” is 2*3+4*5 = 26 Sample Input 5 /*this is show how many Two-Input Function*/ ADD 3 4 ADD MUL 3 4 SUB 2 3 ADD 4 MUL 2 3 MAX 1 MIN ADD 5 1 3 ADD 2 MAX ADD 2 3 MUL 2 3 Sample Output 7 11 10 3 8
5 ответов
+ 5
We are not here to do your homework. If you have specific questions we can help, but nobody should do your homework for you.
+ 2
input number of lines
loop over each line until count above reached
for each loop iteration :
read line
break into words (store words in an array)
write a function that looks at the 1st array element, matching the correct command.
check the next array entry - if number use it, otherwise recursively call yourself to decode another command.
do the same for the 2nd arg, then call the appropriate operation with the 2 arguments based on the original value containing the command name.
key point here is recursion. if you don't know what recursion is, look it up.
0
ok ,but did you can tell me the step or direction for this question?
0
Thanks Udi, exactly my thought.
0
how can I use recursion to found which Function input?