其實……要是直接復制粘貼這個的確是WA……因為可能是因為帖子的原因,one[] 和 two[]字符對不上,需要讀者自己調整下。
另外,這個代碼的巧妙處理避開了這道題目最繞人的地方:單個字符的輸入。
WA的同學看這里:
http://online-judge.uva.es/board//viewtopic.php?f=5&t=5863&sid=91aaddded4ff3586f1e90addd4dd460a
或者我簡要說下:
單字符情況,比如,我輸入 E,只能判定palindrome,而不是mirror;
如果是輸入 4,也是只能判定palindrome,不是mirror(但是兩者原因不同,注意這句話:“A mirrored string is a string for which when each of the elements of the string is changed to its reverse (if it has a reverse) and the string is read backwards the result is the same as the original string.”),重點強調“(if it has a reverse) ”
所以如果既是palindrome,也是mirror,只能是A,O之類的情況(自身mirror自身)