ENG  RUSTimus Online Judge
Online Judge
Задачи
Авторы
Соревнования
О системе
Часто задаваемые вопросы
Новости сайта
Форум
Ссылки
Архив задач
Отправить на проверку
Состояние проверки
Руководство
Регистрация
Исправить данные
Рейтинг авторов
Текущее соревнование
Расписание
Прошедшие соревнования
Правила
вернуться в форум

Обсуждение задачи 1563. Баяны

whats wrong??
Послано Igor 25 окт 2007 02:41
I dont know/My programm out 3 in the 1 test/And it is wrong.But if wright
cout << "3";
it is right/
???????
Re: whats wrong??
Послано timur 25 окт 2007 02:43
Check if you are reading the entire line. Also check if you clean the buffer (cin.ignore()) before reading.
Re: whats wrong??
Послано Igor 25 окт 2007 02:47
i wright
.....
while ( cin.get(c) && (int)c!=10 )
.......
and it is wrong??
Re: whats wrong??
Послано timur 25 окт 2007 02:52
If you checking the new line character I think '\n' is safe.
Re: whats wrong??
Послано Igor 25 окт 2007 02:59
in the end of file there are enter character or not?
Re: whats wrong??
Послано timur 25 окт 2007 03:04
I don't know. I suggest you to use

string s;
getline(cin,s);

to get an entire line in s. Before all this, you need cin.ignore(); to clean the buffer.
Re: whats wrong??
Послано Igor 25 окт 2007 03:19
i've got WA 1/  It does not help.
Re: whats wrong??
Послано Igor 25 окт 2007 03:27
i use
cin >> n;
...
cin.ignore();
while ( i<=n && getline (cin,s) )
    {
        int t=0;
        find (i);
                ++i;
    }
...
cout << sum ;
Re: whats wrong??
Послано timur 25 окт 2007 03:58
What is "find(i)"? May be you don't need getline inside while(*). I don't know if it is allowed, but you can compare yours with my code:

#include <iostream>
#include <string>
#include <set>
using namespace std;

int main()
{
int n;
cin >> n;
set<string> ss;
string s;
int k=0;
cin.ignore();
for (int i=0;i<n;i++) { getline(cin,s); if(ss.find(s)!=ss.end()) k++; else ss.insert(s); }
cout << k;
return 0;
}


Edited by author 25.10.2007 04:00

Edited by author 25.10.2007 04:00
Re: whats wrong??
Послано Igor 25 окт 2007 04:03
i am doing almost the same thing.