zoukankan      html  css  js  c++  java
  • UVa 10226

      题目大意:给出n棵树(有重复),统计每种树出现的频率。使用STL的map。

     1 #include <cstdio>
     2 #include <iostream>
     3 #include <map>
     4 #include <string>
     5 #include <iomanip>
     6 #include <algorithm>
     7 using namespace std;
     8 typedef map<string, int> msi;
     9 
    10 int main()
    11 {
    12 #ifdef LOCAL
    13     freopen("in", "r", stdin);
    14 #endif
    15     int T;
    16     scanf("%d", &T);
    17     getchar();
    18     string str;
    19     getline(cin, str);
    20     msi m;
    21     while (T--)
    22     {
    23         int total = 0;
    24         m.clear();
    25         while (getline(cin, str))
    26         {
    27             if (str[0] == 0)  break;
    28             total++;
    29             m[str]++;
    30         }
    31         for (msi::iterator it = m.begin(); it != m.end(); it++)
    32             cout << it->first << " " << fixed << setprecision(4) << it->second * 100.0 / total << endl;
    33         if (T)  printf("
    ");
    34     }
    35     return 0;
    36 }
    View Code

      这个也是总是Submission error,结果未知...

  • 相关阅读:
    jdk1.8安装与配置
    java编译器——idea的安装
    原型设计作业
    案例分析作业
    202103226-1 编程作业
    阅读任务
    准备工作
    java课程总结
    第十四周总结
    第十三周总结
  • 原文地址:https://www.cnblogs.com/xiaobaibuhei/p/3294391.html
Copyright © 2011-2022 走看看