Link to the problem here
If that's the input from standard input, how do we know when to stop reading. Isn't a sentinel value required?Code:1 10
100 200
201 210
900 1000
Printable View
Link to the problem here
If that's the input from standard input, how do we know when to stop reading. Isn't a sentinel value required?Code:1 10
100 200
201 210
900 1000
That number is a starting value and an ending value the program description says that you must generate all the cycle lengths from i to j inclusively. This problem is neat on the theoretical model where it poses again a state of the haulting problem...briefly stated the haulting problem is: Given some program can you ascertain that it will always hault?" This question was posed by Alan Turing and Alonzo Church when they formalized computation theory Turing used a theoretical FSM known as a Turing machine adn Alonozo Church used lambda calculus Google for the Haulting Problem and you will get more information about this program and others like it.
The example algorithm used a sentinel value of 1.......
You don't have to use a sentinel value, you could just keep reading while the stream is good.
If it's for a class, ask the prof.
gg
This is just one of samples of programming contest problems, whose solution could be submitted through email. I suppose the input would be from screen input therefore doing below won't work and 1 is the sentinel value for the algorithm, not the sentinel value for the *input*.
Code:while (std::cin >> a >> b)
{......}
>> ... below won't work ...
It works fine if you supply an EOF character - cntrl-Z for Dos/Windows, cntrl-D for *nix.
Which means it will work nicely when redirecting input from a file, eg. "prog.exe < input.txt".
gg
redirecting input from a file...yeah I forgot about that. So I guess that's what they will do with their automated submission system.
Thnx a bunch