⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 2474252_ce.cc

📁 北大大牛代码 1240道题的原代码 超级权威
💻 CC
字号:
#include <stdio.h>
#include <map>
#include <malloc.h>

struct species {
   char s[81];
} buf;

bool operator==(const species &a, const species &b) {
   return !strcmp(a.s, b.s);
}

bool operator<(const species &a, const species &b) {
   return strcmp(a.s, b.s) < 0;
}

map<species,int> cnt;

main(){
   int tot = 0;
   while(gets(buf.s)){
      cnt[buf]++;
      tot++;
   }
   for (map<species,int>::iterator i = cnt.begin(); i!=cnt.end(); *i++) {
      printf("%s %0.4lf\n",i->first.s, 100.0*i->second/tot);
   }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -