题解
2023-07-01 19:48:35
发布于:上海
72阅读
0回复
0点赞
#include<bits/stdc++.h>
using namespace std;
char m[1005],k[105],ans[1005];
int lenm,lenk,j;
bool jud(char x)
{ return (x>='a'&&x<='z')? true : false;
}
int main()
{ gets(k);
gets(m);
lenm=strlen(m);
lenk=strlen(k);
for(int i=0,j=0;i<lenm;i++,j++)
{ if(j>=lenk)j=0;
if(jud(m[i]))
{ if(!jud(k[j]))k[j]+='a'-'A';
ans[i]=m[i]-(k[j]-'a');
if(ans[i]<'a')ans[i]+=26;
}
else
{ if(jud(k[j]))k[j]-='a'-'A';
ans[i]=m[i]-(k[j]-'A');
if(ans[i]<'A')ans[i]+=26;
}
}
cout<<ans;
return 0;
}
全部评论 2
/code/judger/run/4999444141518618721/main.cpp: In function 'int main()':
/code/judger/run/4999444141518618721/main.cpp:9:5: error: 'gets' was not declared in this scope
{ gets(k);
^~~~
/code/judger/run/4999444141518618721/main.cpp:9:5: note: suggested alternative: 'fgets'
{ gets(k);
^~~~
fgets2024-09-21 来自 四川
0编译错误: /code/judger/test/1836745938021306368/main.cpp: In function 'int main()':
/code/judger/test/1836745938021306368/main.cpp:9:5: error: 'gets' was not declared in this scope
{ gets (k);
^~~~
/code/judger/test/1836745938021306368/main.cpp:9:5: note: suggested alternative: 'fgets'
{ gets (k);
^~~~
fgets2024-09-19 来自 天津
0
有帮助,赞一个