早教吧作业答案频道 -->其他-->
一道很简单的ACM题,求大神看看我错在哪儿了,C++YoumusthaveheardofanancientencryptioncalledCaesarcipheror'shiftcipher'.Thatis,giventheplaintextandanumberD,youshouldreplaceeverycharactercintheplaintextwithan
题目详情
一道很简单的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
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
#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
看了 一道很简单的ACM题,求大神...的网友还看了以下:
求下列几个饮料的标准英文单词红葡萄酒白葡萄酒啤酒橙汁可乐雪碧请按顺序列出它们的英文单词很多汉语可以 2020-05-14 …
新概念2第二单元大概是什么水平?大概听到新概念2的mp3第二单元结尾部分,有的课文就非常吃力了.然 2020-06-03 …
高分求英语达人分享英语单词高效背法高三了,于是特地去买了本高中必背单词.发现现在背单词很困难!1 2020-06-06 …
求英语经典语录~大家能不给我多多一点英语经典语录~爱情.还有生活的!因为我发现我背单词很慢但是被文 2020-06-13 …
我需要点字体变形的词语或成语,单词也行…如简单的画蛇添足类似的.因为老师要求很多.我需要点字体变形 2020-06-17 …
英语作文ontheweekends作文要求很简单,单词不太深刻,只要简单就行了,不少于35个单词, 2020-07-11 …
求助,英语单词,很急求助几个英语单词尿袋,扩阴器,侧螺旋,中螺放,钩扣式,十字阀,推拉阀,吸塑包装 2020-07-11 …
请以WhyareBicyclessopopularinchina?为题,根据下列要求写100-120 2020-11-28 …
英语作文:新华中学的学生李明,学英语有点问题,请根据提示和要求写一篇短文,说说帮助他提高英语的建议1 2020-12-10 …
我的英语很差,单词记得不多,单独记单词很不好记,求一篇包含很多常...我的英语很差,单词记得不多,单 2021-02-05 …