![:-)](./images/smilies/icon_smile.gif)
Best regards
DM
Moderator: Board moderators
Tahseen Mohammad wrote:It seems there is a lot of guessing going on about the input format.
Whether there is extra spaces before, after and within author names.
There is nothing like that. Input is precisely like that of sample.
So painful parsing is not necessary.
What does "whitespace" mean for you? isspace() from <ctype.h> ?Per wrote:Here's a detailed description (for reading an entire author, first and last name):
1. Skip whitespace
2. Add until null or ',' (there's your first name)
3. If we stopped on a ',': skip past it.
4. Skip whitespace
5. Add until null or ',' or ':' or whitespace (there's your last name)
6. Repeat reading names this way until the last char was null or ':'.
I guess you could translate this to char-by-char reading by just replacing null by "'\n' or eof".
I had it already ACepted but with a version where I copy strings around a lot. This is too slow for my liking. I have a faster one that always gives WA and I don't understand why.alu_mathics wrote:Thanks PER.
My first solution gave me W.A.
After a long period of time (may be 6 months) i just read your message (the input section) and finally got A.C.
without using STL.
To CDiMa i consider whitespace as ' ' , '\t' && '\r'.
hope this will help you.
Code: Select all
Smith, M.N., Chen, X., Johnson: Introduction to Algorithms
Code: Select all
Smith, M.N., Chen, X., Johnson, I.R.: Introduction to Algorithms