杭电ACM 1004 Let the Balloon Rise 运行没问题,但就是Compilation Error
#include<iostream>#include<string.h>usingnamespacestd;typedefstructballoon{charcolour...
#include<iostream>
#include<string.h>
using namespace std;
typedef struct balloon
{
char colour[16];
int count=0;
};
int main(void)
{
int n,i;
char temp[16];
balloon b[1001];
while (cin >> n)
{
if (n == 0)
return 0;
memset(b,0,sizeof(balloon)*1000);
while (n--)
{
cin >> temp;
for (i = 0; b[i].count!=0; i++)
{
if (!(strcmp(temp, b[i].colour)))
b[i].count++;
}
b[i].count++;
strcpy(b[i].colour, temp);
}
int max = 0;
for (i = 0; b[i].count != 0; i++)
{
if (b[i].count > max)
{
max = b[i].count;
strcpy(temp, b[i].colour);
}
}
cout << temp << endl;
}
return 0;
} 展开
#include<string.h>
using namespace std;
typedef struct balloon
{
char colour[16];
int count=0;
};
int main(void)
{
int n,i;
char temp[16];
balloon b[1001];
while (cin >> n)
{
if (n == 0)
return 0;
memset(b,0,sizeof(balloon)*1000);
while (n--)
{
cin >> temp;
for (i = 0; b[i].count!=0; i++)
{
if (!(strcmp(temp, b[i].colour)))
b[i].count++;
}
b[i].count++;
strcpy(b[i].colour, temp);
}
int max = 0;
for (i = 0; b[i].count != 0; i++)
{
if (b[i].count > max)
{
max = b[i].count;
strcpy(temp, b[i].colour);
}
}
cout << temp << endl;
}
return 0;
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询