求助(c++)
查看原帖
求助(c++)
461581
Endstone_V楼主2021/8/21 12:21

求助,这个有什么问题!哪位dalao可以帮帮我

/*oops!This code had a big problem!!!!!!!*/ 
#include<bits/stdc++.h>
using namespace std;
char b[1000000],n[1000000],s[1000000];
int k[27];
int main(){
	cin>>b>>n>>s;
	int len=strlen(b);
	if(len<26){
		printf("Failed");
		return 0; 
	}
	for(int i=1;i<=len;i++){
		k[b[i]-'@']=n[i]-'@';//下标是密文,内容是明文
		for(int j=1;j<=26;j++){
			if(k[j]==k[b[i]-'@']&&j!=(b[i]-'@')){
				printf("Failed");
				return 0;
			}
			
			if(i!=1&&n[i-1]-'@'!=k[b[i-1]-'@']){
				printf("Failed");
				return 0;
			}
		}
	}
	for(int i=0;i<=len;i++){
		if((int)(k[s[i]-'@']+'@')>=65 && (int)(k[s[i]-'@']+'@')<=90)
		printf("%c",k[s[i]-'@']+'@');
	}
}
2021/8/21 12:21
加载中...