zoukankan      html  css  js  c++  java
  • poj2418 map 快排水过

    /*计算每个单词的百分比按字典序输出*/


    #include <cstdio>
    #include<cstdlib>
    #include <cstring>
    #include <cctype>
    #include <string>
    #include <map>
    #include <algorithm>
    #include <iostream>

    using namespace std;

    struct tt
    {
        char w[40];
        bool operator < (const tt a)const
        {
            int t = strcmp(w,a.w);
            if(t < 0)
                return true;
            return false;
        }
    };

    int n;
    map<string,int>sad;
    map<string,bool>sadd;
    tt tre[10100];

    int main()
    {
        //freopen("input.in","r",stdin);
        char str[40];
        int count = 0;
        memset(tre,0,sizeof(tre));
        n = 0;
        while(fgets(str,35,stdin) != NULL)
        {
            if(str[0] == ' ')
                break;
            int len = strlen(str);
            str[len-1] = '';
            count++;
            if(!sadd[str])
            {
                strcpy(tre[n++].w,str);
                sadd[str] = true;
            }
            sad[str]++;
        }
        sort(tre,tre+n);
        for(int i = 0;i < n;i++)
        {
            double temp = 1.0*sad[tre[i].w] / count *100;
            printf("%s %.4lf ",tre[i].w,temp);
        }
        return 0;
    }

  • 相关阅读:
    接口自动化架构-获取用例
    Windows性能监控工具Perfmon使用指南
    接口自动化架构1-setting
    多进程
    线程锁、守护线程
    多线程
    xlrd模块
    封装写日志的类
    封装redis
    继承
  • 原文地址:https://www.cnblogs.com/hanbinggan/p/4463878.html
Copyright © 2011-2022 走看看