I'm sorry this is actually my first program in C++. I've done this program in pascal before, and i just 'translated' in C++. The sample input and output works, but time limit exceeds. Am i doing something wrong? It works fine on Ideone.
#include <iostream>
using namespace std;
int main ()
{
int a, b;
bool c;
c=false;
while (true)
{
cin >> b;
if (b == 42)
c = true;
else if (c == false)
cout << b << "\n";
}
return 0;
}