I don't know what the wrong if,help!
PLOBLEM 1:
I have seen the topic "c WA why?",and I have a problem:Why the for cycle's range should be 1 to 2*n but not 1 to n?Help me,I don't know.
PLOBLEM 2:
my program:
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int n,max=0,count[3],a;
char s[30],ans,max1;
int main()
{
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
scanf("%d",&n);
count[1]=0;count[2]=0;count[3]=0;
for(int i=1;i<=2*n;i++)
{
scanf("%s",s);
if(s[0]=='E')
{
count[1]++;
if(count[1]>max) {max=count[1];max1='E';}
}
else if(s[0]=='L')
{
count[2]++;
if(count[2]>max) {max=count[2];max1='L';}
}
else if(s[0]=='M')
{
count[3]++;
if(count[3]>max) {max=count[3];max1='M';}
}
}
if(max1=='E') printf("Emperor Penguin");
else if(max1=='L') printf("Little Penguin");
else if(max1=='M') printf("Macaroni Penguin");
return 0;
}
It can be right in my conputer(printf"Macaroni Penguin"),but it's WRONG#1 in the test.
And if I change for cycle's range into 1 to n,it's WRONG,and printf"Emperor Penguin"
I don't know.
SO,please help me,thank you!
now,this problem can pass #6 point,but W7
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int n,max=0,count[3],a;
char s[30],ans,max1,e=0,l=0,m=0;
int main()
{
scanf("%d\n",&n);
count[1]=1;count[2]=1;count[3]=1;
for(int i=1;i<=2*n;i++)
{
scanf("%s",s);
if(s[0]=='E') e++;
else if(s[0]=='L') l++;
else if(s[0]=='M') m++;
}
if(e>l&&e>m) printf("Emperor Penguin");
if(l>e&&l>m) printf("Little Penguin");
if(m>e&&m>l) printf("Macaroni Penguin");
//system("pause");
return 0;
}
Edited by author 24.02.2013 07:27
Edited by author 24.02.2013 07:42