As a C++ beginner, I tried solving some beginner problems such as the 'Hashmat the Brave Warrior' UVA problem. This problem requires me to output the difference between 2 numbers in an input, where the input will be terminated by "End of File".
Example input:
10 12
10 14
100 200
output:
2
4
100
This is my code:
#include <iostream>
using namespace std;
int main(){
int a, b;
while (cin >> a >> b){
cout << max(a,b) - min(a,b) << endl;
}
}
Even though I entered nothing, the program is still running, therefore this solution is wrong for the problem. So when I upload my solution the virtualjudge account, they interpret it as wrong solution. How do I make the program such that it ends with 'End of File'?