as u see, the input method of most of the task are in many lines.
how can i know when the input ends?
just a Q
Moderator: Board moderators
Re: just a Q
Most of problems have end of input in specification. Very often is end of file as number 0(zero) or end of file. You have to check and control end of input in your program.ywceric wrote:as u see, the input method of most of the task are in many lines.
how can i know when the input ends?
Learn, learn, learn.
..
well..
if you have a number of test cases.. you just do a for cycle.. if your task is to read until end of file just control EOF (end of file).
For example scanf returns the number of arguments read if the value returned is 0 then input ends.
gets function is almost like that.. if 0 is returned then no more lines to read, so you can do these to read all input while (gets(line)) {...}
if you have a number of test cases.. you just do a for cycle.. if your task is to read until end of file just control EOF (end of file).
For example scanf returns the number of arguments read if the value returned is 0 then input ends.
gets function is almost like that.. if 0 is returned then no more lines to read, so you can do these to read all input while (gets(line)) {...}
Neo