добавлен исходный код и ссылки
This commit is contained in:
parent
c83ed6cf42
commit
4be7b9c4ce
15 changed files with 438 additions and 1 deletions
19
01-знакомство-с-языком-d/src/chapter-1-4-1/app.d
Normal file
19
01-знакомство-с-языком-d/src/chapter-1-4-1/app.d
Normal file
|
@ -0,0 +1,19 @@
|
|||
import std.stdio, std.string;
|
||||
import std.algorithm;
|
||||
|
||||
void main()
|
||||
{
|
||||
size_t [string] dictionary;
|
||||
foreach (line; stdin.byLine())
|
||||
{
|
||||
// Разбить строку на слова
|
||||
// Добавить каждое слово строки в словарь
|
||||
foreach (word; line.strip.splitter)
|
||||
{
|
||||
if (word in dictionary) continue; // Ничего не делать
|
||||
auto newID = dictionary.length;
|
||||
dictionary[word.idup] = newID;
|
||||
writeln(newID, '\t', word);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue