So the exercise is:
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
So... My solution was this one:
/ Life, the Universe, and Everything Written by laurene 21/07/2013 /
#include <stdio.h>
int main()
{
int num[10];
int i = 0;
while(1)
{
scanf ("%d", &num[i]);
i++;
if (num[i-1] == 42)
{
scanf ("%d", &num[i]);
for (i = 0; num[i] != 42; i++)
{
printf ("%d\n", num[i]);
}
return(0);
}
}
return(0);
}
The Result is something like this:
1
2
3
42
44
1
2
3
Process returned 0 (0x0) execution time : 4.757 s
Press any key to continue.
So! I can type even one number after typing 42, and there is the output, all the numbers before 42!
But! The site compiler keeps telling that my solution does have a Run Time Error, that I can't figure out what it is...
And the Admin solution to this problem gives a different answer, you guys can check in the submittion list.
I would love to know what that Run Time Erros is all about.
Thanks for the attention.