Блог пользователя Qualified

Автор Qualified, история, 6 лет назад, По-английски

Hi, I am trying to do 723B - Text Document Analysis and here is my code.

Code

When I input 37, which is the example input, the program just returns maxx and cnt. I don't understand this. Am I doing something wrong. BTW I am using GVim.

  • Проголосовать: нравится
  • -20
  • Проголосовать: не нравится

»
6 лет назад, скрыть # |
 
Проголосовать: нравится +14 Проголосовать: не нравится

After you do cin >> n, the pointer for your input is still on the same line as n. So then getline returns the remainder of that line, which is just a newline character. Changing getline to cin >> s should fix the error, since s is guaranteed to not have spaces.

Also, your code doesn't separate words if the separator is ( or ). Printing s1 inside the while loop will demonstrate this.

»
6 лет назад, скрыть # |
Rev. 3  
Проголосовать: нравится -14 Проголосовать: не нравится