文章

4

粉丝

0

获赞

1

访问

1.2k

头像
变位词 题解:先sort()排序再比较
P1032
发布于2024年3月22日 21:59
阅读数 169

#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
bool judge(string s1,string s2){
    sort(s1.begin(),s1.end());//排序后比较
    sort(s2.begin(),s2.end());
    if(s1==s2)
        return true;
    else
        return false;
}
int main(){
    int n;
    while(cin>>n){
        string s1,s2;
        for(int i=0;i<n;i++){
            cin>>s1>>s2;
            if(judge(s1,s2)){
                cout<<"Yes"<<endl;
            }
            else...

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发