ACM/HDU1006 Let the Balloon Rise,让气球上升

Contest time again! How excited it is to see balloons floating around. But to tell you a secret, the judges’ favorite time is guessing the most popular problem. When the contest is over, they will count the balloons of each color and find the result.

思路: 用a数组记录不同的单词,b数组记录该单词的出现次数,每输入一个单词进行一次判断,如果a中没这个单词,则a中添加这个单词,如果已经出现过,那么对应的b[i]加1。
优点: 和其他进行多次循环,嵌套循环的方法相比,每次输入完进行判断,输入完毕便直接输出的效率显然更高~~也是刚刚做完,欢迎大家给予建议。acm/HDU,代码可AC。

#include<stdio.h>
#include<string.h>
int max(int a,int b) //比较两个数大小,返回大的值 
{
	if(a<b)return b;
	else return a;
}
int main()
{
	int n;
	while(scanf("%d",&n)&&n!=0) //输入N个数,0结束 
	{
	char a[1000][15]={0};     /*数组a[i]储存不同的单词,由于循环,进行
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值