-
Notifications
You must be signed in to change notification settings - Fork 0
UVa 156
WinDaLex edited this page Sep 15, 2013
·
1 revision
from Volume 1. Elementary Problem Solving :: Sorting/Searching
Anagram 指的是对于某个单词来说, 仅仅调换了字母排列顺序的单词。给出一个字典, 它含有多个单词, 找出里面不是其他单词 anagram 的单词。按字典序输出。
要判断两个单词是否为对方的 anagram,只需要将他们全部变为小写字母,然后对他们内部的字母进行排序,最后看得到的字符串是否相等即可。
会判断 anagram 后, 剩下的枚举和字典序输出就很简单了。枚举和字典序输出, 也可以利用一下 STL 的 set 或 map 一同解决。