作者:yunjinqi 类别:
日期:2023-06-04 18:55:16
阅读:426 次 消耗积分:0 分
#include <stdio.h>
#include <string.h>
int main(){
char lower_alpha[27] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char upper_alpha[27] = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char c;
char arr[80];
int offset=0;
int count=0;
int index=0;
while (scanf("%c",&c)!=EOF && c!='\n'){
arr[count]=c;
count++;
}
if (scanf("%d",&offset)!=EOF){
//printf("%d\n",offset);
}
for (int i=0;i<count;i++){
c = arr[i];
if (c>='a' && c<='z'){
for (int j=0;j<26;j++){
if (lower_alpha[j]==c){
index=(j+offset)%26;
while (index<0){
index+=26;
}
printf("%c",lower_alpha[index]);}
}
}else if (c>='A' && c<='Z'){
for (int j=0;j<26;j++){
if (upper_alpha[j]==c){
index=(j+offset)%26;
while (index<0){
index+=26;
}
printf("%c",upper_alpha[index]);}
}
}else{
printf("%c",c);
}
}
printf("\n");
return 0;
}