ENG  RUS Timus Online Judge
Online Judge
Problems
Authors
Online contests
Site news
Webboard
Problem set
Submit solution
Judge status
Guide
Register
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

## Discussion of Problem 1585. Penguins

c WA why?
Posted by Wang Fei 13 Feb 2008 18:08
#include<stdio.h>
void main()
{
int n,i;
int e=0,m=0,l=0,max;
char ch;
scanf("%d",&n);
for(i=0;i<n;i++)
{
fflush(stdin);
ch=getchar();
switch(ch)
{
case 'E':e++;break;
case 'M':m++;break;
case 'L':l++;
}
}
max=e;ch='E';
if(m>max){max=m;ch='M';}
if(l>max) ch='L';
switch(ch)
{
case 'E':printf("Emperor Penguin");break;
case 'M':printf("Macaroni Penguin");break;
case 'L':printf("Little Penguin");
}
}
Re: c WA why?
Posted by Rustambek_UWED 22 Apr 2008 13:02
Do not use
<stdio.h>

#include <iostream>
using namespace std;

good luck
Re: c WA why?
Posted by Denis Koshman 21 Jul 2008 13:03
I never use iostream. Try to add \n to output.
Re: c WA why?---Change your code like this...!--Good Luck
Posted by Mister Bean 18 Dec 2008 14:56
#include<stdio.h>
void main()
{
int n,i,e=0,m=0,l=0,max;
char ch[30];
scanf("%d",&n);
for(i=0;i<2*n;i++)
{
scanf("%s",ch);
switch(ch[0])
{
case 'E':e++;break;
case 'M':m++;break;
case 'L':l++;
}
}
max=e;ch[0]='E';
if(m>max){max=m;ch[0]='M';}
if(l>max) ch[0]='L';
switch(ch[0])
{
case 'E':printf("Emperor Penguin");break;
case 'M':printf("Macaroni Penguin");break;
case 'L':printf("Little Penguin");
}
}