作业帮 > 综合 > 作业

一道很简单的ACM题,求大神看看我错在哪儿了,C++

来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/05/05 05:20:50
一道很简单的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
#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