输出一摸一样判错
查看原帖
输出一摸一样判错
251098
_LurminShax_楼主2023/11/3 22:09

测评机又在抽什么风

#include<iostream>
using namespace std;
int main(){
    string S1, S2, S3;
    cin>>S1>>S2>>S3;
    int S[26] = {0};//原文对应字符ASCLL
    bool SChack[26] = {0};//ASCLL是否已被占用
    for(int i = 0 ; i < S1.length(); i++){
        if(S[S1[i] - 'A' + 1] != 0){
            if(S[S1[i] - 'A' + 1] != S2[i] - 'A' + 1){
                cout<<"Failed"<<endl;
                //system("pause");
                return 0;
            }
        }
        else{
            S[S1[i] - 'A' + 1] = S2[i] - 'A' + 1;
        }
    }
    for(int i = 0 ; i < 26; i++){
        if(SChack[S[i] - 1]){
            cout<<"Failed"<<endl;
            //system("pause");
            return 0;
        }
        else{
            SChack[S[i] - 1] = 1;
        }
    }
    for(int i = 0 ; i < S3.length(); i++){
        cout<<(char)(S[S3[i] - 'A' + 1] + 'A' - 1);
    }
    cout<<endl;
    //system("pause");
    return 0;
}
2023/11/3 22:09
加载中...