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

Обсуждение задачи 1612. Трамвайный форум

@Admin : some problem about string in C++
Послано FireHeart 23 окт 2008 06:42
First, plz read my source.

#include <iostream>
#include <cstdio>
#include <vector>
#include <map>

using namespace std;

int main()
{
    map <string, int> forum;
    string s;

    while ( getline (cin, s))
    {
        if (s == (string)"tram") forum["tram"]++;
        if (s == (string)"trolleybus") forum["trolleybus"]++;
    }
    if (forum["trolleybus"] > forum["tram"]) cout << "Trolleybus driver" << endl;
    if (forum["trolleybus"] < forum["tram"]) cout << "Tram driver" << endl;
    else cout << "Bus driver" << endl;

    system("pause");
    return 0;
}

Ok. This solution's result is "Compilation error".
One of its :

e8411d95-0fcd-44e7-941f-abd986747ed6(13): error: identifier "getline" is undefined
      while ( getline (cin, s))
              ^

But I've seen FAQs, "getline" just use <iostream>. I don't why but I think my solution is take another error, not a "Compilation error".

Plz explain ! Thank you very much !

P.S : Sorry about my bad English.
Re: @Admin : some problem about string in C++
Послано Vladimir Yakovlev (USU) 23 окт 2008 22:10
add
#include <string>