3 Star 0 Fork 0

mirrors_ClickHouse/countwords

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
simple.d 382 Bytes
一键复制 编辑 原始数据 按行查看 历史
Ross Lonstein 提交于 2021-03-16 06:24 +08:00 . d-language simple & optimized
import std.stdio;
import std.string;
import std.algorithm.sorting : schwartzSort;
void main() {
int[string] freq;
while (! stdin.eof) {
string line = stdin.readln().toLower();
foreach (string word; line.split) {
freq[word]++;
}
}
auto ordered = schwartzSort!(k => freq[k], "a > b")(freq.keys);
foreach (k; ordered){
writeln(k, " ", freq[k]);
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mirrors_ClickHouse/countwords.git
git@gitee.com:mirrors_ClickHouse/countwords.git
mirrors_ClickHouse
countwords
countwords
master

搜索帮助