How can we find the end of input file?
I think it's easy problem we can use something like
binary search for find answer , but how can we read
input data :
if it will be input.txt we can do like that
while not eof do
but it's now console
Re: How can we find the end of input file?
You don't need to use binary search
All numbers can be stored in extended type
Re: How can we find the end of input file?
Posted by
Delete 1 Jan 2007 03:45
If so then it's very simple, but i'm getting WA :(
Isn't simple recurse with sqrt() function not right? why?
I obviously can't read the input correctly.
I do it this way:
while not eof do
begin
read(a);
...
end;
...
Is that right?
Edited by author 01.01.2007 04:03
Edited by author 01.01.2007 04:03
Re: How can we find the end of input file?
Yes of course sqrt(), but
trouble is to get numbers from flow
You should read text char by char until eof
Numbers can be stored in array without recursion
Edited by author 01.01.2007 04:33
Re: How can we find the end of input file?
Posted by
Kit 1 Jan 2007 13:00
You can use "seekeof" function instead of "eof". It presented even in BP7.0, so you can easily find description.
Reading data is fully described in FAQ - http://acm.timus.ru/faq.aspx (-)
Re: How can we find the end of input file?
Yes of course sqrt(), but
trouble is to get numbers from flow
You should read text char by char until eof
Numbers can be stored in array without recursion
Edited by author 01.01.2007 04:33
I'm stupid :)
It can be solved simple with seekeof
while not seekeof do
...
read(number);
...
Edited by author 01.01.2007 15:22Re: How can we find the end of input file?
How I can do it on C++ ??
see FAQ again (-)
Posted by
Kit 1 Jan 2007 21:01
Edited by author 01.01.2007 21:02
Re: see FAQ again (-)
thanks, seekeof works fine :)
Re: How can we find the end of input file?
Posted by
Jerry 3 Feb 2007 13:22
Yes,I can't do it too!
It annoyed me for a long time:
[code deleted]
Where's my problem!
Edited by author 03.02.2007 13:22
Edited by moderator 13.02.2007 20:57
Re: How can we find the end of input file?
1-st "int" is not enough to input
2-nd try to use printf instead setprecision.
Re: How can we find the end of input file?
Here is your AC program:
But better is to use only array, not stack!!!
[code deleted]
Edited by moderator 13.02.2007 20:57
Re: How can we find the end of input file?
Posted by
Squid 4 Feb 2007 02:41
And how can I find the end of input using Java? FAQ says nothing about it...
Does it work?
while (in.nextToken() != StreamTokenizer.TT_EOF) {
// ...
}