2022.11.04 PM 11:00 by CBJ
來源 : https://zerojudge.tw/ShowProblem?problemid=a009 出題者 : ACM 標籤 : 字元處理 難易度 : 0.2
解題想法 : 找出規律,將 "解碼後" 的字串轉回 "原文"
//C language
//solution link(含註解): https://github.com/CBJ0519/CBJsProgramDiary.com/blob/main/zj/a009.c
#include<stdio.h>
int main(){
char s[1000];
fgets(s,1001,stdin);
for(int i=0;s[i]!='\n';i++){
s[i]=s[i]-7;
}
printf("%s",s);
return 0;
}

//C++ language
//solution link(含註解): https://github.com/CBJ0519/CBJsProgramDiary.com/blob/main/zj/a009.cpp
#include<iostream>
using namespace std;
int main(){
char s[1000];
fgets(s,1001,stdin);
for(char &c:s){
if(c=='\n') break;
c-=7;
}
cout<<s;
return 0;
}

## Python language
## solution link(含註解): https://github.com/CBJ0519/CBJsProgramDiary.com/blob/main/zj/a009.py
s=input()
ans=''
for i in s:
ans+=chr(ord(i)-7)
print(ans)

發佈留言