ASCII 表

P1914 小书童——密码

 

题解

1.本题都是小写字母唉

2.把字母取模27   得到对应单词表顺序1···26

3.后移并且取模26  如果得到0,那么证明它是 z (122),否则对应加上96,回归对应字母

 

代码

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>

using namespace std;

int n;
char s[51];

int main()
{
    scanf("%d\n",&n);
    gets(s);
    for(int i=0;i<=strlen(s)-1;i++)
    {
        s[i]=(s[i]-96)%27;
        s[i]=(s[i]+n)%26;
if(s[i]==0) s[i]=122;
else s[i]+=96;

    }
    for(int i=0;i<=strlen(s)-1;i++)
      printf("%c",s[i]);
    
}

 

相关文章:

  • 2021-10-02
  • 2021-07-04
  • 2021-11-23
  • 2022-02-02
  • 2022-01-03
  • 2021-08-23
  • 2021-11-06
  • 2021-06-25
猜你喜欢
  • 2021-12-31
  • 2022-12-23
  • 2021-12-15
  • 2021-08-29
  • 2022-12-23
  • 2021-06-30
  • 2022-02-07
相关资源
相似解决方案