So I'm doing acm programming practice problems and I'm always stuck on getting input from user. I'm using C++. So I need to read input from user and it could be multiple lines or a single line we don't know. So if the input is as follow:
2
1 2 3 4 5
2 2 2
The first line represent the number of games that the user play and the lines follow are the scores. The end of each game will be terminated by a newline. I need to read those lines and store it somewhere. How do I go about doing that? I've looked on websites and it seems like most people use scanf or cin or getline but I have no clue what those does.
Another example:
12 21
13 43
1 4
A C
0 0
Each line will contain the two number I need to add, separated by whitespace. When I see two zeros, the input is done. How do I read these and check if it's 0 0? I tried something like:
string num1;
while (true) {
getline(cin,num1);
if (num1.empty()) {
break;
}
}
But it didn't work. Please help I think I know how to solve the problem but I can't the point of getting input from user. Thanks