E - god is a girl 字符处理

E - god is a girl
Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u

Description

One day,when I was dreaming,god went into my dream,she was pretty cute,just like /^_^\... 
I really wanted to talked to her,but my English was so poor and she was not a national god but a foreign one...After thirty minutes,she flew away...but story was not finished here,she had left a letter for me!!!What puzzled me so much is the letter was encoded.I had thought for many days,but still can't get it. Now I turn to you for help,with some limited prompts,can you help me to decode the whole letter? 

Prompts: 
GDJIJ,EL SSJT UT YWOSQNIVZMI. -> HELLO,MY NAME IS LINDAINVERS. 
CN WLP JRVMFGQ BVR,IJCFI? -> DO YOU REQUIRE AID,HUMAN? 
NMAB VYNNF, FI'E VC HP IXJ ZLQZI. -> ONCE AGAIN, IT'S UP TO THE ELVES. 
... 

Input

There is multy cases,please process to EOF. 
Each case is one line of string with uppercase letters and white spaces and other symbols. 

Output

One line of the decoded string.

Sample Input

SGC CGGJX GC BMHVQ BGU BCIHNYNBX GNPLV!

Sample Output

THE FLOWS OF MAGIC ARE WHIMSICAL TODAY!


#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include<cstdio>
#include<iostream>
#include <map>
using namespace std;

char a[50]="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
char s[1000010],b;
int i,chan,num=0;
int  f[100010],x,j;
int main()
{
    f[0]=1;
    f[1]=1;
    for(int i=2;i<=100000;i++)
    f[i] = (f[i-1]%26+f[i-2]%26)%26;
     while(gets(s)!=NULL)
     {
     	num = 0;
     	chan=strlen(s);
	    for(i=0;i<chan;i++)
	    {
	     	if(s[i]<'A'||s[i]>'Z')
	     		printf("%c",s[i]);
	     	else
	     	{
			    for(j=0;j<=25;j++)
	     	    	if(s[i]==a[j])
	     			{
	     				x=j;
	     				break;
			 		}	
			 	x+=f[num];
			 	x=x%26;
			 	printf("%c",a[x]);
			 	num++;
		    }
		}
		printf("\n");
	}
    return 0;
}





  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值