首页 > 其他 > 详细

啊啊啊啊啊啊啊啊啊啊啊真是刷了一道有意义的题哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈 杭电1004

时间:2016-04-06 21:36:19      阅读:180      评论:0      收藏:0      [点我收藏+]

输入字符串,并比较输入频率最大的那个字符串

#include<iostream>
using namespace std;
int  main( )
{
    int round;
    cin >> round;
    while (round)
    {
        char ballo[1001][16];
        int fre[1001] = { 0};
        char tem[15];
        int m = 0, n = 0;
        int count = 0;
        for (int i = 0; i < round; i++)
        {
            cin >> tem;
            int j = 0;
            while (j != i && strcmp(tem,ballo[j]))
            {
                j++;
            }
            if (!strcmp(tem,ballo[j]))
                fre[j]++;
            else
            {
                strcpy_s(ballo[j], tem);
                fre[j]++;
                count++;
            }
        }
        int max = fre[0];
        int pos = 0;
        for (int u = 0; u < count; u++)
        {
            if (fre[u]>max)
            {
                max = fre[u];
                pos = u;
            }
        }
        cout << ballo[pos]<<endl;
        cin >> round;
    }
    return 0;
}


Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2016 HDU ACM Team. All Rights Reserved.
Designer & Developer Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2016-04-06 21:16:47, Gzip enabled
 
 

啊啊啊啊啊啊啊啊啊啊啊真是刷了一道有意义的题哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈 杭电1004

原文:http://www.cnblogs.com/chendashennihao/p/5361172.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!