早教吧作业答案频道 -->其他-->
一道很简单的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题,求大神...的网友还看了以下:
分式的加减法小丽和小米一起区买面粉,一月份,小丽买了a千克,小米用了b元钱,此时面粉单价为m元/千 2020-05-13 …
物理公式不仅反映了物理量之间的关系,也确定了单位间的关系.现有物理量单位:m(米)、s(秒)、C( 2020-05-14 …
物理公式不仅反映了物理量之间的关系,也确定了单位间的关系.现有物理量单位:m(米)、J(焦)、N( 2020-05-14 …
物理公式v=rw怎么觉得单位不对V的单位是m/s,r的单位是m,w的单位是rad/s,那么rw的单 2020-06-12 …
请问一下线速度单位怎么出来的?线速度单位是m/s,而线速度=半径×角速度,角速度为rad/s,半径 2020-06-17 …
液柱压力公式中的单位是怎么得来的?P=ρ×g×hp-液柱产生的压力,n/m^2ρ-液体密度,单位g 2020-06-18 …
请问vt-v0=at中的at是什么啊?a的单位是m/s2,t的单位是s,那相乘不就等于m/s3了吗 2020-07-08 …
长度的单位是m,面积的单位是m^2,体积的单位是m^3,那么有没有什么的单位是m^4?如果有,意义 2020-07-20 …
图1为某区域的水系分布图。某校研究性学习小组对图1中的M地进行实地考察,并查阅了相关资料,发现近三十 2020-12-25 …
关于X的方程(2x+m)/(x-2)=3的解是正数,求m的取值范围是不是m=6且m≠-4我承认这题实 2020-12-31 …