听取wa声一片

P1914 小书童——凯撒密码

乱写
by Justin_love_coding @ 2024-05-16 08:55:33


6 , 所以怎么改呢
by yiwanni @ 2024-05-19 23:07:48


最好用字符数组做。
by mairuisheng @ 2024-05-24 19:18:34


@[mairuisheng](/user/1328579) 谢谢,我试试
by yiwanni @ 2024-05-26 08:38:33


```c #include <bits/stdc++.h> using namespace std; char s[55];//字符数组s[55]。 int n,i,t; int main() { cin>>n; cin>>s; int l=strlen(s);//strlen函数求s长度。 for(int i=0;i<l;i++) { t=s[i];//将字符赋值给整型数组,返回ASCII码值。 if((t+n)>122)//根据ASCII码,z是122,而再大就是其他字符了。 { s[i]-=26;//因为n最大26,所以只需减一个26(小写字母有26个) } s[i]+=n;//字符+整型返回字符 cout<<s[i];//输出 } return 0; } ```
by mairuisheng @ 2024-05-26 20:35:10


附上ASCII码表一份: ![ASCII码表](https://file1.renrendoc.com/fileroot_temp2/2020-11/12/530cb2dc-7c68-4552-b4d5-f61df854fdfb/530cb2dc-7c68-4552-b4d5-f61df854fdfb1.gif) *来自百度
by mairuisheng @ 2024-05-26 20:38:54


怎样贴代码呢?
by chenzhongmugu @ 2024-08-01 14:38:06


|