Guys, even if any of those hideous solutions work, which is a lot to say for the very first and easiest problem ever to exist, they will land you a time of 0.01.
The I/Ostream library is SLOW as hell - depending on what you read/write to the stream, they are at LEAST 10 times slower than the standart reading/writing functions in stdio. Use stdio.h.
About the problem - try the following:
#include <stdio.h>
int main() {
int x; //= 0 init
scanf("%d", &x);
while(x != 42) {
printf("%d\n", x);
scanf("%d", &x);
}
return 0;
}
There are still better approaches to the problem.