【一道很简单的ACM题,求大神看看我错在哪儿了,C++You-查字典问答网
分类选择

来自阮康成的问题

  【一道很简单的ACM题,求大神看看我错在哪儿了,C++YoumusthaveheardofanancientencryptioncalledCaesarcipheror'shiftcipher'.Thatis,giventheplaintextandanumberD,youshouldreplaceeverycharactercintheplaintextwithan】

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

  YoumusthaveheardofanancientencryptioncalledCaesarcipheror'shiftcipher'.Thatis,giventheplaintextandanumberD,youshouldreplaceeverycharactercintheplaintextwithanothercharacterwhichisDplacesaftercinthealphabet.Forexample,ifD=2,youshouldreplace'a'with'c',replace'b'with'd',...replace'y'with'a',andreplace'z'with'b'.

  GiventheplaintextandD,youshouldoutputtheciphertext.

  InputThefirstlineisanintegerT,thenumberoftestcases.ThenTcasesfollows.

  Eachcasecontainsonlyoneline,consistsoftheplaintextandthenumberD,separatedbyaspace.Youcanassumethereareonlylowercaselettersintheplaintext,andthelengthisnomorethan100.0≤D>a)

  {

  for(i=0;i>s>>n;

  intl=strlen(s);

  for(intj=0;j

1回答
2020-06-0316:48
我要回答
提示:回答问题需要登录哦!
阮加勇

  #include

  #include

  usingnamespacestd;

  intmain()

  {

  inta,i,n;

  chars[111];//这里可以开大一点,因为结尾还有一个字符是'';

  while(cin>>a)

  {

  for(i=0;i>s>>n;

  intl=strlen(s);

  for(intj=0;j'z')//这里还可能超出字母的范围

  k-=26;

  cout

2020-06-03 16:48:46
大家都在问
最新问答