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
tatai_talukder: 2016-07-17 17:25:44

Okay how many test cases does it need to have? I mean how many does the program accepts? Is it user defined or fixed at 5 as the example?

monarchchakri: 2016-07-17 08:56:23

In reply to some comments i would like to say that there is no specific difference between the use of endl and"\n" because I was able to execute the code using both and the submission was correct !!

karishma_mit: 2016-07-16 22:58:18

How does the user tell the programs that it is done entering all the numbers and is now ready for the output?

saba_rish91: 2016-07-15 17:51:20

Man! Spent so much time figuring out what I did wrong! The program requires "\n" when printing the output. I was using endl !

randomguy1: 2016-07-14 04:25:26

I've written a code which runs fine on my PC. Doesn't seem to work here. I am "hard-coding" the array. How to pass on the array?

adityago786: 2016-07-10 09:57:09

my code Is running on ideone it but shows wrong answer on submission..

naveen_333: 2016-07-09 14:25:57

how input is supposed to be taken?

aexpo: 2016-07-04 08:17:45

no sorting is required at all!
If the input contains 42 at some place,then you know how to break the loop,
if 42 is never in the input ,then you have to read all the inputs as it is and print it!
In this case,use
scanf("%d",&n)!=-1
{
}
and this will terminate the loop,once the file reading is completed!
Now,since the array size is not mentioned,(go for vector ,if you know STL)else,just define the size as 100
and go on storing in the array,when it is about to get full just copy this to another array and name that array as the previous one's name after deleting the pointer to previous array!
Hope i am clear!

wander4096: 2016-07-04 02:51:52

1

Last edit: 2016-07-04 02:52:07
danielphillips: 2016-07-02 21:09:02

Make sure your output includes a line break. Otherwise the output isn't formatted correctly. Caught me out.


Added by:mima
Date:2004-05-01
Time limit:10s
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%
369 74