TEST - Life, the Universe, and Everything


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

Information

In case of any problems with your code, you can take a look in the forum, you'll find the answer, only for this problem, in various languages.


hide comments
k_hitesh_1124: 2024-09-08 10:05:21

bro can anyone explain what we should do, i have wrote the code for user given values, self assumed values, but nothing is right
[Simes]: read the values from standard input. Don't write anything not given in the example, so no prompts or messages,

Last edit: 2024-09-08 19:43:37
nihitha_2004: 2024-08-30 19:56:18

<snip>
not able to submit, but my code is right
[Simes]: what if the input is split across multiple lines?

Last edit: 2024-08-31 07:20:15
siddhant925: 2024-08-30 19:39:23

<snip>
#is this correct ?
[Simes]: Not quite, your output must match the expected output exactly, so try it without the prompt.

Last edit: 2024-08-31 07:17:52
jiangyixuan: 2024-08-13 11:31:56

在SPOJ AC的第一道题目
[Simes]: "The first question in SPOJ AC" - You do realise your submission history is publicly accessible don't you?

Last edit: 2024-08-14 19:50:27
cucatly_: 2024-08-10 04:17:35

<snip>
My codes is right ,but your website keep telling that it it wrong answer. WHY???
[Simes]: try putting some newlines between the numbers.

Last edit: 2024-08-12 20:03:47
ducbantanh: 2024-07-26 16:04:19

use this line of code:

int n;
while(cin >> n){
//code here
}

Last edit: 2024-07-26 16:26:41
cyq_lyw_01: 2024-07-24 15:15:14

uAKIOI

muba_4058: 2024-07-11 11:48:21

a=[1,2,88,42,99]
for num in a:
if num==42:
break
print (num)

is this wrong answer?
But it’s actually working.

[Simes]: yes, it's wrong because the example I/O is just that - an example. Your progam will be tested with different values, unknown to you, that your program must read from the standard input.

Last edit: 2024-07-15 22:36:50
p_shaw: 2024-06-28 10:50:48

Here's a Python solution using a simple loop:

python
<snip>
Explanation:
1. We use an infinite loop (while True) to keep reading input.
2. For each input number, we check if it equals 42.
3. If it is, we break out of the loop.
4. Otherwise, we print the number.

[Simes]: No thanks, people are encouraged to write their own solutions.

Last edit: 2024-06-28 11:18:08
jairamji: 2024-05-30 04:11:27

can you tell me is the input wrong or something else is off in my code :-<snip>
[Simes]: this is not the place for debugging code, please use the forum.

Last edit: 2024-05-30 07:22:31

Added by:mima
Date:2004-05-01
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All
Resource:Douglas Adams, The Hitchhiker's Guide to the Galaxy

Problem's scores 2 votes

Concept difficulty
Concept difficulty 6%
Implementation difficulty
Implementation difficulty 7%
375 74