While Delshire's code does work and gets AC, it has one interesting quirk.
while(a <= 100)
It is given in the problem statement that the numbers "are integers of one or two digits" so this works fine. It would be more acceptable to see:
while(true)
or, since it is given that there is always a 42 in the input statement:
while(a != 42)
This last segment also removes the need for the extra break, giving the loop a single exit point.
#include <iostream>
using namespace std;
int main() {
int a = 0;
while(a != 42) {
cin >> a;
if(a != 42)
cout << a << endl;
}
}