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

that is not like a computer in my code?
Posted by viktorius 14 Jul 2013 02:09
#include<stdio.h>
#include<string.h>
int comp(char *pen,char *peng)
{
    int i;
    for(i=0;i<strlen(pen);i++)
        if(pen[i]!=peng[i])
            return 0;
    return 1;
}
int main()
{
    int i,a=0,b=0,c=0,n;
    char pen[3][10]={"Emperor","Little","Macaroni"},peng[20];
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        fflush(stdin);
        gets(peng);
        if(comp(pen[0],peng))
            ++a;
        if(comp(pen[1],peng))
            ++b;
        if(comp(pen[2],peng))
            ++c;
    }
    if(a>b&&a>c)
        printf("Emperor Penguin");
    if(b>a&&b>c)
        printf("Little Penguin");
    if(c>b&&c>a)
        printf("Macaroni Penguin");
    return 0;
}
Re: that is not like a computer in my code?
Posted by viktorius 14 Jul 2013 02:48
figured out, you need to clear the buffer perverted by
scanf ("% * [^ \ n] ");
and used to enter the
scanf ("% s ", peng);