题目大意:给出n棵树(有重复),统计每种树出现的频率。使用STL的map。
#include <cstdio>
#include <iostream>
#include <map>
#include <string>
#include <iomanip>
#include <algorithm>
using namespace std;
typedef map<string, int> msi; int main()
{
#ifdef LOCAL
freopen("in", "r", stdin);
#endif
int T;
scanf("%d", &T);
getchar();
string str;
getline(cin, str);
msi m;
while (T--)
{
int total = ;
m.clear();
while (getline(cin, str))
{
if (str[] == ) break;
total++;
m[str]++;
}
for (msi::iterator it = m.begin(); it != m.end(); it++)
cout << it->first << " " << fixed << setprecision() << it->second * 100.0 / total << endl;
if (T) printf("\n");
}
return ;
}
这个也是总是Submission error,结果未知...