杭电oj 1004题在vc6上运行正确但总是wrong answer

2024-11-30 18:20:26
推荐回答(1个)
回答1:

统计个数问题:
#include
#include
#include
using namespace std;
struct node
{
int count;
char color[15];
}*c;
int main()
{
int n,i,j,max=1;
char pop[15];
while(cin>>n,n)
{
c=(struct node*)malloc(sizeof(c[0])*n);
cin>>c[0].color;
c[0].count=1;
strcpy(pop,c[0].color);
for(i=1;i {
c[i].count=1;
cin>>c[i].color;
for(j=0;j {
if(strcmp(c[i].color,c[j].color)==0)
c[i].count++;
if(c[i].count>max)
{
max=c[i].count;
strcpy(pop,c[i].color);
}
}
}
cout< }
return 0;
}