What's the end of inputs ?? :-s
There is just one test case. You should read the input till the end of file.
while (cin >> num) { ... }
In order to post something you must login first. You can use the form in the top of this page.