Sphere Online Judge

SPOJ Problem Set (classical)

1. Life, the Universe, and Everything

Problem code: TEST

Your program is to use the brute-force approach in order to find the Answer to Life, the Universe, and Everything. More precisely... rewrite small numbers from input to output. Stop processing input after reading in the number 42. All numbers at input are integers of one or two digits.

Example


Input:
1
2
88
42
99

Output:
1
2
88

Added by:Michał Małafiejski
Date:2004-05-01
Time limit:10s
Source limit:50000B
Languages:All except: TECS
Resource:Douglas Adams, The Hitchhiker's Guide to the Galaxy

hide comments
2010-09-01 17:22:53 Jashwant
my doubt is whether the program should stop reading inputs after 42 or else it can read but while printing should print only the numbers before 42.?
2010-08-31 23:00:04 mohamed mahmoud elshenawy
supplied file is not a correct jar archive.
what i shoud do?????
2010-08-28 15:17:10 menna
how will reading input stop?!!!

2010-08-28 15:17:10 jerry
var n:longint;
begin
repeat
readln(n);
if n=42 then break;
writeln(n);
until n=42;
end.

Last edit: 2010-08-23 03:01:29
2010-08-28 15:17:10 njabulo msomi
When will the program will stop reading an inputs?

Last edit: 2010-08-17 16:07:40
2010-08-28 15:17:10 rajalakshmi
while(input!=42)
2010-08-28 15:17:10 Chandra sekar
@Futhorcly Qunty Solom
Any input that is given after 42 is neglected (that is, it is not printed). so, in this case, 99 comes after 42. hence, u should not print it as output.
2010-08-28 15:17:10 Futhorcly Qunty Solom
I can't understand the 99 of input;
who can tell me?
2010-08-28 15:17:10 John
@Sohamn Pramanik:
That's your choice, however you want to do it, it is supposed to work. (and if you can, try not to do it in Java, 'cause it's very slow :)) Good luck.

Last edit: 2010-08-04 04:09:14
2010-08-28 15:17:10 Sohamn Pramanik
Are the Inputs to be taken one by one and Outputs to be printed correspondingly? Or First all the Inputs and then all Outputs together? PLEASE REPLY !
SPOJ System © 2010 Sphere Research Labs. All Rights Reserved.