Hi, can someone please tell me how to read the inputs mentioned below.
l
Laurent Laborde
02/01/2023, 6:23 AM
call readln() twice ?
do you have a sample input ? the format of the line 1 isn’t clear
s
Salman
02/01/2023, 6:26 AM
image.png
4 is the size of array, followed by 4 integers that needs to be in array, and then some number in nextline, it is easy to do in c++ but here I am stuck 🙂
l
Laurent Laborde
02/01/2023, 6:27 AM
readln().split(' ’)
look like a jetbrain academy exercise
s
Salman
02/01/2023, 6:29 AM
image.png
this is how I have done this, but still giving some number format exception
l
Laurent Laborde
02/01/2023, 6:31 AM
val myarray = readln().split(’ ’)
this should be enough.
you can deal with the conversion to int when using the values later
i have to go, good luck 🙂
a
Ayfri
02/01/2023, 6:35 AM
Also I would advice you to use Intellij Community Edition (or Ultimate if you are a student) instead of VSCode :)
s
Salman
02/02/2023, 5:41 AM
sure @Ayfri, this is just some online editor I was using to solve a competitive problem, however I still don’t think that I was able to explain the question I posted above ,
Referring the screenshot below, from Ist line I want first digit (4) to sore in an int variable and next four digits (1, 2,3 ,4 ) to be stored in separate integer array, how can I do this please.