zoj2104(水题一枚)

 1 #include <stdio.h>
 2 #include <algorithm>
 3 #include <cstring>
 4 using namespace std;
 5 
 6 struct str
 7 {
 8     char s[30];
 9     int num;
10 };
11 
12 str a[1005];
13 
14 void init(int k)
15 {
16     for(int i=0;i<k;i++)
17     {
18         a[i].num=0;
19     }
20 }
21 
22 
23 int cmp(str a , str b)
24 {
25     return a.num>b.num;
26 }
27 
28 int main()
29 {
30     int j;
31     int n;
32     char b[30];
33     while(1)
34     {
35 
36         scanf("%d",&n);
37         if(n==0)break;
38         init(n);
39         scanf("%s",a[0].s);
40         int count=0;
41         for(int i=1;i<n;i++)
42         {
43             scanf("%s",b);
44             for(j=0;j<=count;j++)
45             {
46                 if(strcmp(b,a[j].s)==0)
47                 {
48                     a[j].num++;
49                     break;
50                 }
51             }
52             if(j-1==count) strcpy(a[++count].s,b);
53         }
54         sort(a,a+count+1,cmp);
55         printf("%s\n",a[0].s);
56     }
57 
58     return 0;
59 }

对时间什么的要求的都不高,不涉及什么算法,只要不脑残,绝对快速AC

转载于:https://www.cnblogs.com/devil-91/archive/2012/08/11/2633864.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值