ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1612. Tram Forum

@Admin : some problem about string in C++
Posted by FireHeart 23 Oct 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++
Posted by Vladimir Yakovlev (USU) 23 Oct 2008 22:10
add
#include <string>