📄 1869880_ac_0ms_20k.c
字号:
# include <stdio.h>
# include <string.h>
int main()
{
int k, i, n;
int plaincode[80], ciphercode[80];
char plaintext[80], ciphertext[80];
while(scanf("%d",&k)==1&&k)
{
memset(ciphertext,'0',sizeof(ciphertext));
scanf("%s",ciphertext);
n = strlen(ciphertext);
memset(plaintext,'0',n);
for(i = 0; i < n; i++)
{
switch(ciphertext[i])
{
case '_': ciphercode[i] = 0;break;
case '.': ciphercode[i] = 27;break;
default : ciphercode[i] = (int)ciphertext[i]-96;
}
plaincode[(k*i)%n]=(ciphercode[i]+i)%28;
if(plaincode[(k*i)%n]<0) plaincode[(k*i)%n]+=28;
switch(plaincode[(k*i)%n])
{
case 0: plaintext[(k*i)%n] = '_';break;
case 27: plaintext[(k*i)%n] = '.';break;
default : plaintext[(k*i)%n] = (char)(plaincode[(k*i)%n]+96);
}
}
plaintext[n] = '\0';
puts(plaintext);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -