解译密码

//将密码译回原文,方式为把第i个字母变成第(26-i+1)个字母,非字母不变
#include<stdio.h>
int main()
{
	int i;
	int j;
	char ch[80];
	char tran[80];
	printf("input cipher code:");
	gets(ch);
	printf("\ncipher code:%s",ch);
	i=0;
	while(ch[i]!='\0')
	{
		if((ch[i]>='A')&&(ch[i]<='Z'))
		{
			tran[i]=155-ch[i];
		}
		else if((ch[i]>='a')&&(ch[i]<='z'))
		{
			tran[i]=219-ch[i];
		}
		else
		{
			tran[i]=ch[i];
		}
		i++;
	}
	j=i;
	printf("\nnoriginal text:");
	for(i=0;i<j;i++)
	{
		putchar(tran[i]);
	}
	printf("\n");
	return 0;
}

你可能感兴趣的:(while,密码,if)