sortseq.prog
上传用户:gzelex
上传日期:2007-01-07
资源大小:707k
文件大小:1k
开发平台:

MultiPlatform

  1. Using a sorted sequence to list all elements in a sequence of strings lying
  2. lexicographically between two given search strings.
  3. #include $<$LEDA/sortseq.h$>$
  4. main()
  5. ${$ 
  6. hspace*{.5cm}sortseq<string,int> $S$;
  7. hspace*{.5cm}string $s_1,s_2$;
  8. smallskip
  9. hspace*{.5cm}While ( cin $>>$ $s_1$ &&  $s_1$ != ``stop'' )  $S$.insert($s_1,0$);
  10. smallskip
  11. hspace*{.5cm}While ( cin $>>$ $s_1$ $>>$ $s_2$ )
  12. hspace*{1.5cm}${$ seq_item $stop = S$.locate($s_2$);
  13. smallskip
  14. hspace*{1.8cm}For (seq_item $it = S$.locate($s_1$); $it$ != $stop$; $it = S$.succ($it$))\
  15. hspace*{2.6cm}cout $<<$ $S$.key($it$) $<<$ ``$backslash$"; 
  16. hspace*{1.5cm}$}$
  17. smallskip
  18. $}$