ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1032. Find a Multiple

Numbers input
Posted by Амаяк 6 Dec 2022 11:55
How do I get an unlimited length array from the console so that the test starts? What is the end character of the input?
Re: Numbers input
Posted by GeekCmore 6 Dec 2022 16:39
When you use scanf(), generall you can check the return value of scanf(). If the return value is equal to -1, it means that it gets the end of input. Besides, you when you use cin, you can just judge if the input is end by the return value of cin is 0 or not. If it is 0, it means the end.
eg:
int main(){
    int n;
    while(scanf("%d", &n) != -1){
    ....
    }
}

and

int main(){
    int n;
    while(cin >> n){
    ....
    }
}