In lots of hackathon they provide testcases. So in those test cases they provide inputs in different ways through STDIN. This is one of the situation I struggle at all.
This is one kind of a input: (This is one testcase)
Mike John Ahmed Sangha Daniel Ann So here I have 6 inputs. But they don't provide number of inputs. So I can't use for loop or while loop to take this input. Because I don't know how many iteration I should do. So I have to take inputs until end. But this is not a input from a file. So I can't use EOF as well. This input is from STDIN. So how can I take this kind of input and store it in an array? Also I don't know how many elements should create in array. Because I don't know how many number of inputs are there. (different testcases may contain different number of inputs). How can I solve this kind of a problem?
please provide solutions for do this in c, c++ or in both languages.
Thank you so much for the help!
https://stackoverflow.com/questions/65948249/how-to-take-this-kind-of-a-stdin-inputs-in-c January 29, 2021 at 11:07AM
没有评论:
发表评论