d_array.prog

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

PROG
58
字号
{\bf Program 1}:Using a dictionary array to count the number of occurences of the elements in a sequence of strings.\bigskip\#include $<$LEDA/d\_array.h$>$main()$\{$\hspace*{.5cm}d\_array\<string,int\> $N(0)$;\hspace*{.5cm}string $s$;\smallskip\hspace*{.5cm}{\bf while} (cin \>\> $s$) $N[s]++$;\smallskip\hspace*{.5cm}{\bf forall\_defined}($s,N$)             cout \<\< $s$ \<\< ``  " \<\< $N[s]$ \<\< endl;\smallskip $\}$\\\bigskip{\bf Program 2}:Using a d\_array to realize an english/german dictionary.\bigskip\#include $<$LEDA/d\_array.h$>$main()$\{$\smallskip\hspace*{.5cm}d\_array\<string,string\> $trans$;\smallskip\hspace*{.5cm}$trans$[``hello"]\hspace{.13cm}= ``hallo";\\\hspace*{.5cm}$trans$[``world"]= ``Welt";\\\hspace*{.5cm}$trans$[``book"]\hspace{.13cm}= ``Buch";\\\hspace*{.5cm}$trans$[``key"]\hspace{.37cm}= ``Schluessel";\smallskip\hspace*{.5cm}string $s$;\hspace*{.5cm}{\bf forall\_defined}($s,trans$)               cout \<\< $s$ \<\< ``  " \<\< $trans[s]$ \<\< endl;\smallskip$\}$

⌨️ 快捷键说明

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