# [C語言] b516. 凱撒密碼-商競103
## C語言
## 觀念:
1. getchar是在<stdlib.h>底下
2. ASCII code用法要背熟
3. input=(input-65+3)%26+65;
- $-65$ 代表要將
$65$|-----|$90$ 改成 $0$|-----|$25$
A|-----|Z     A|-----|Z
- $+3$ 代表加密
$0$|-----|$25$ 改成 $3$|-----|$28$
A|-----|Z    A|-----|Z
- $+65$ 代表要將
$3$|-----|$28$ 改成 $68$|-----|$67$
A|-----|Z     A|-----|Z
## AC程式碼:
```
#include<stdio.h>/* for printf and scanf */
#include<stdlib.h>/* for getchar */
int main(){
int a=0,i=0;
char input;
while(scanf("%d",&a)!=EOF){
for(i=0;i<a;i++){
while((input=getchar())!=EOF){
if(input>=65 && input<=90){
input=(input-65+3)%26+65;
printf("%c",input);
}
else{
printf("\n");
}
}
}
}
return 0;
}
```
Reference:
[1] [b516. 凱撒密碼-商競103](https://zerojudge.tw/ShowProblem?problemid=b516)