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 1585. Penguins

Hello,everything works but still gives WA on Test1
Posted by Nikita 17 Oct 2013 12:56
#include <iostream>
using namespace std;
int main ()
{
    short int i, n1, n2, n3;
    cin >> i;
    cin.sync();
    char *name1, *name2, *name3, *name  = new char[20];
    n1 = n2 = n3 = 0;
    name1 = "Emperor Penguin";
    name2 = "Macaroni Penguin";
    name3 = "Little Penguin";
    while (i > 0)
    {
        cin.getline(name,19);
        cin.sync();
        switch(name[0])
        {
        case 'E': n1++;
            break;
        case 'M': n2++;
            break;
        case 'L': n3++;
            break;
        }
        i--;
    }
    if (n1 > n2 && n1 > n3)
        printf("%s",name1);
    else
        if (n2 > n1 && n2 > n3)
        printf("%s",name2);
        else
            if(n3 > n1 && n3 > n2)
            printf("%s",name3);
    system("pause");
    return 0;
}