一道很简单的ACM题,求大神看看我错在哪儿了,C++You must have heard of an ancient encryption called Caesar cipher or 'shift cipher'.That is,given the plaintext and a number D,you should replace every character c in the plaintext with an

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/11 22:49:04
一道很简单的ACM题,求大神看看我错在哪儿了,C++You must have heard of an ancient encryption called Caesar cipher or 'shift cipher'.That is,given the plaintext and a number D,you should replace every character c in the plaintext with an
xTMkA+/x| 4 `/&촛eg65zim[DXMQ R[EIz/lx".;|2Y@<F&a$PہBae|5L͒K%M}d% PRn2@*zܨ.)B_ rS(ܧ1QUFmCu0 fYr Zh)Ce7\8Eu8̀?o,j*r柔A`2;0?x$6w}xpAa0dI] 5fBA^쌤ԇÇ'k<*\J$5 )c/RWƤ *|c SLP*qOaor tv-.76;O㏳,߾?lnmwV7;kkhnmį_>kmZ/@i꼿/nc NCgy>lG4Lˏv{ĻArDI7>

一道很简单的ACM题,求大神看看我错在哪儿了,C++You must have heard of an ancient encryption called Caesar cipher or 'shift cipher'.That is,given the plaintext and a number D,you should replace every character c in the plaintext with an
一道很简单的ACM题,求大神看看我错在哪儿了,C++
You must have heard of an ancient encryption called Caesar cipher or 'shift cipher'.That is,given the plaintext and a number D,you should replace every character c in the plaintext with another character which is D places after c in the alphabet.For example,if D = 2,you should replace 'a' with 'c',replace 'b' with 'd',...replace 'y' with 'a',and replace 'z' with 'b'.
Given the plaintext and D,you should output the cipher text.
InputThe first line is an integer T,the number of test cases.Then T cases follows.
Each case contains only one line,consists of the plaintext and the number D,separated by a space.You can assume there are only lower case letters in the plaintext,and the length is no more than 100.0 ≤ D < 26.
OutputOutput one line for each test case,indicating the cipher text.
Sample Input2
tjucs 1
abcd 0
Sample Outputukvdt
abcd
我的代码:
#include
#include
using namespace std;
int main()
{
int a,i,n;
char s[99];
while(cin>>a)
{
for(i=0;i>s>>n;
int l=strlen(s);
for(int j=0;j

一道很简单的ACM题,求大神看看我错在哪儿了,C++You must have heard of an ancient encryption called Caesar cipher or 'shift cipher'.That is,given the plaintext and a number D,you should replace every character c in the plaintext with an
#include
#include
using namespace std;
int main()
{
int a,i,n;
char s[111]; //这里可以开大一点,因为结尾还有一个字符是'\0';
while(cin>>a)
{
for(i=0;i>s>>n;
int l=strlen(s);
for(int j=0;j'z') //这里还可能超出字母的范围
k-=26;
cout