⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 1129 do the untwist.cpp

📁 ACM 威士忌部分答案
💻 CPP
字号:
#include <cstdio>
#include <string>
using namespace std;
char cipher[80];
char plain[80];

int main()
{
	int i,j,n,key,ccode,pcode,p;
	
	while( scanf("%d",&key)==1 && key )
	{
		scanf("%s",cipher);
		n=strlen(cipher);
		
		for(i=0;i<n;i++)
		{
			switch(cipher[i])
			{
			case '_':
				ccode=0;
				break;
			case '.':
				ccode=27;
				break;
			default :
				ccode=cipher[i]-'a'+1;
				break;
			}
			pcode=ccode+i;
			while(pcode>=28)//注意这儿 
				pcode-=28;
			p=key*i % n;
			switch(pcode)
			{
			case 0:
				plain[p]='_';
				break;
			case 27:
				plain[p]='.';
				break;
			default :
				plain[p]=pcode+'a'-1;
			}
		}
		plain[n]=0;
		printf("%s\n",plain);
	}
	return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -