- 字符串还原
- 2020-08-11 09:56:06 @
裂开
2 条评论
-
zimboss (zimboss) LV 6 @ 2020-08-20 09:31:19
自己顶一下自己
-
2020-08-16 15:00:52@
八和十一直过不了,换了思路能过了,但还是不清楚原来的错在哪里了
#include<stdio.h> #include<stdlib.h> #include<string.h> char ABC[80]="abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"; void Com(char s[],int k,char B[],char C[],int n){ int i,j; for(i=0;i<n;i++){ for(j=26;j<53;j++){ if(s[i]==ABC[j]){ B[i]=ABC[j+k]; C[i]=ABC[j-k]; break; } } } } void print(char s[],int n){ for(int j=n-1;j>=0;j--){ printf("%c",s[j]); } } int main(){ int n; scanf("%d",&n); char Fir[10001]; char F1[10001], F2[10001], F[10001]; char Sec[10001]; char S1[10001], S2[10001], S[10001]; char Thi[10001]; char T1[10001], T2[10001], T[10001]; scanf("%s",Fir); scanf("%s",Sec); scanf("%s",Thi); for(int i=0;i<n;i++){ F[i]=Fir[n-1-i]; } for(int i=0;i<n;i++){ S[i]=Sec[n-1-i]; } for(int i=0;i<n;i++){ T[i]=Thi[n-1-i]; } for(int k=0;k<7;k++){ Com(Fir,k,F1,F2,n+1); Com(Sec,k,S1,S2,n+1); Com(Thi,k,T1,T2,n+1); if((strcmp(S2,F)==0&&strcmp(T1,F)==0)||(strcmp(S1,F)==0&&strcmp(T2,F)==0)) { print(Fir,n); break; } else if((strcmp(F2,S)==0&&strcmp(T1,S)==0)||(strcmp(F1,S)==0&&strcmp(T2,S)==0)) { print(Sec,n); break; } else if((strcmp(S2,T)==0&&strcmp(F1,T)==0)||(strcmp(S1,T)==0&&strcmp(F2,T)==0)) { print(Thi,n); break; } else{ } } }
- 1