0

Anyone can help me

The given code takes 3 numbers as input. Complete the program to output the maximum of the 3 inputs. And i try this code input <- readLines('stdin') x <- as.integer(input[9]) y <- as.integer(input[56]) z <- as.integer(input[42]) print(max(56)) Why did't work?

4th Apr 2022, 10:30 PM
Rizki Fauziah Arief
4 Answers
+ 4
print(max(x,y,z))
5th Apr 2022, 3:21 AM
Simba
Simba - avatar
+ 1
You need to find a maximum number from x,y,z not 56. Take a look at the lessons about max() and input once.
5th Apr 2022, 2:16 AM
Simba
Simba - avatar
0
How about this? input <- readLines('stdin') x <- as.integer(input[1]) y <- as.integer(input[2]) z <- as.integer(input[3]) print (max(y))
5th Apr 2022, 3:03 AM
Rizki Fauziah Arief
0
This will definitely work, try it input <- readLines('stdin') x <- as.integer(input[1]) y <- as.integer(input[2]) z <- as.integer(input[3]) print (max(x,y,z))
30th Apr 2023, 3:27 PM
🇼🇳Mohammad Iqbal
🇼🇳Mohammad Iqbal - avatar