您的位置:首页 > 其它

Ural1585(细节)

2015-03-05 13:59 218 查看
题目链接:点击打开链接

解题思路:

很简单,但细节很坑。用getline之前要来个getchar把输入n后的回车吃掉,经过被加速器坑过这么多次后,我就决定以后还是不用加速器了。

完整代码:

#include <algorithm>
#include <iostream>
#include <cstring>
#include <climits>
#include <cstdio>
#include <string>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
typedef long long LL;
const int MOD = int(1e9)+7;
const int INF = 0x3f3f3f3f;
const double EPS = 1e-9;
const double PI = acos(-1.0); //M_PI;
string s;
int max(int a , int b , int c)
{
    int k = a > b ? a : b;
    return k > c ? k : c;
}

int main()
{
    #ifdef DoubleQ
    freopen("in.txt","r",stdin);
    #endif

    int n;
    cin >> n;
    int a = 0 , b = 0 , c = 0;
    getchar();
    for(int i = 0 ; i < n ; i ++)
    {
        getline(cin , s);
        if(s == "Emperor Penguin")
            a ++;
        else if(s == "Little Penguin")
            b ++;
        else if(s == "Macaroni Penguin")
            c ++;
    }
    int res = max(a , b , c);
    if(res == a)
        cout << "Emperor Penguin" << endl;
    else if(res == b)
        cout << "Little Penguin" << endl;
    else if(res == c)
        cout << "Macaroni Penguin" << endl;
}


更多精彩请访问:点击打开链接
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: