Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* http://tw.knowledge.yahoo.com/question/question?qid=1512030105710 */
- #include <algorithm>
- #include <iostream>
- #include <string>
- int main()
- {
- /* 需要兩個字串 */
- std::string s1, s2;
- while (1)
- {
- /*
- * !(std::cin >> s1) 判斷輸入是否失敗
- * s1 == "STOP!!" 判斷輸入是不是 "STOP!!"
- * 以上兩個成立任一個,跳出 while 迴圈
- */
- if (!(std::cin >> s1) || s1 == "STOP!!")
- break;
- if (!(std::cin >> s2) || s2 == "STOP!!")
- break;
- /* 排序 */
- std::sort(s1.begin(), s1.end());
- std::sort(s2.begin(), s2.end());
- /* 比較,相等印 "yes"、不相等印 "no" */
- std::cout << (s1 == s2 ? "yes" : "no") << std::endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement