C++ 字符串通配符变位词判断
#include
bool isWildcard(string s1, string s2) { sort(s1.begin(), s1.end()); sort(s2.begin(), s2.end());
return s1 == s2;
}
int main() { string s1, s2; cin >> s1 >> s2;
if (isWildcard(s1, s2)) {
cout << 'A' << endl;
} else {
cout << 'N' << endl;
}
return 0;
}
AI 优化版
原文地址:https://www.cveoy.top/t/topic/quiY 著作权归作者所有。请勿转载和采集!