📄 1899.cpp
字号:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <map>
#include <algorithm>
using namespace std;
char a[10001][31];
map<string,int> table;
int Comp(const void* a,const void* b)
{
char* aa=(char*)a;
char* bb=(char*)b;
return strcmp(aa,bb);
}
int main()
{
int i,j,cnt,char_num,count,cas=1;
char s[31];
//freopen("in.txt","r",stdin);
cnt=0;
count=0;
while(gets(s))
{
count++;
if(table.count(s)==0)
{
strcpy(a[cnt++],s);
table.insert(make_pair(s,1));
}
else
++table[s];
while(gets(s)&&strlen(s)!=0)
{
count++;
if(table.count(s)==0)
{
strcpy(a[cnt++],s);
table.insert(make_pair(s,1));
}
else
++table[s];
}
qsort(a,cnt,sizeof(a[0]),Comp);
if(cas!=1) putchar('\n');
for(i=0;i<cnt;i++)
printf("%s %.4lf\n",a[i],table[a[i]]*100.0/count);
cnt=0;;
count=0;
cas++;
table.clear();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -