|
|
back to boardPlease help! Wrong answer 5! #include<stdio.h> int main(void){ int n,i,k1,k2,k3; char s[30]; scanf("%d",&n); k1=k2=k3=0; for(i=1;i<=n;i++){ scanf("%s",s); if(s[0]=='E') k1++; else if(s[0]=='L') k2++; else k3++; } if(k1>k2 && k1>k3) printf("Emperor Penguin"); else if(k2>k1 && k2>k3) printf("Little Penguin"); else if(k3>k1 && k3>k2) printf("Macaroni Penguin"); return 0; } Re: Please help! Wrong answer 5! Function "scanf" reads array of char and stops when meet any white-space symbol (space, carriage return, tab). So when input contain "Emperor Penguin" first time you get "Emperor", second time you get "Penguin". Second part of string gives you k3++. Edited by author 21.05.2012 11:45 Re: Please help! Wrong answer 5! Thank you! |
|
|