dic.prog

来自「This software was done in part for a tex」· PROG 代码 · 共 31 行

PROG
31
字号
Using a dictionary to count the number of occurrences of the elements in a sequence of strings, terminated by string ``stop''.\smallskip\#include \<LEDA/dictionary.h\>\smallskipmain()\\$\{$\hspace*{.5cm} dictionary\<string,int\> $D$;\smallskip\hspace*{.5cm} string $s$;\\\hspace*{.5cm} dic\_item $it$;\smallskip\hspace*{.5cm} {\bf while} (cin \>\> $s$)\hspace*{1.5cm} $\{$\  $it = D$.lookup($s$);\\\hspace*{1.85cm} if ($it==nil$) $D$.insert($s,1$);\\\hspace*{1.85cm} else $D$.change\_inf($it$,$D$.inf($it$)+1);\\\hspace*{1.5cm} $\}$\smallskip\hspace*{.5cm} {\bf forall\_items}($it,D$) cout \<\< $D$.key($it$) \<\< `` : " \<\<  $D$.inf($it$) \<\< endl;\\\smallskip$\}$\\

⌨️ 快捷键说明

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