добавлен исходный код и ссылки

This commit is contained in:
Alexander Zhirov 2023-01-22 15:43:59 +03:00
parent c83ed6cf42
commit 4be7b9c4ce
15 changed files with 438 additions and 1 deletions

View file

@ -0,0 +1,28 @@
import std.algorithm, std.stdio, std.string;
void main()
{
// Рас­счи­тать таб­ли­цу час­тот
uint[string] freqs;
foreach (line; stdin.byLine())
{
foreach (word; line.strip.splitter)
{
++freqs[word.idup];
}
}
// На­пе­ча­тать таб­ли­цу час­тот
foreach (key, value; freqs)
{
writefln("%6u\t%s", value, key);
}
// На­пе­ча­тать таб­ли­цу час­тот с сортировкой
string[] words = freqs.keys;
sort!((a, b) { return freqs[a] > freqs[b]; })(words);
foreach (word; words)
{
writefln("%6u\t%s", freqs[word], word);
}
}