I normally use C#, but have started using C++ for some other sites.
How do I handle the input for:
spoj.pl/problems/PARKINGL/2
I can't figure out how to know when to make my program terminate.
created
last reply
- 7
replies
- 150
views
- 4
users
- 1
link
I normally use C#, but have started using C++ for some other sites.
How do I handle the input for:
spoj.pl/problems/PARKINGL/2
I can't figure out how to know when to make my program terminate.
simes,
No worries
How do I read the blank line? Using scanf and cin the app just sits waiting, it's not reading the blank line.
int getInt()
{
char s[10];
cin >> s;
printf("-%d-\n",s[0]);
return atoi(s);
}
I put the above sample together, it won't print anything for the blank line though. The other method was replacing the cin line with scanf("%s", &s);
Ah I see.
I've not used C or C++ for a long while now, but if you read the 1st character of the line using a %c, you'll either get a carriage return (windows) or a line feed (*nix). If you get something else, read the remainder of the line, put it all together and convert it to an integer.
But there's probably a better way!
Topic | Category | Replies | Views | Activity |
---|---|---|---|---|
SPTTRN1 - Straight Line Spiral Pattern (Act 1) | C and C++ | 0 | 14 | 6d |