NOJ [1263] All Kill

来源:互联网 发布:软件架构师常用工具 编辑:程序博客网 时间:2024/06/06 07:35
  • 问题描述
  • Now is the Z country's extraordinary period,Ning x City broke out in a procession, the relevant departments accidentally get some data, by analysis, 
    this is M country' ciphertext. . . Now, we get the correct way to decryption .
    Now,you have to do it, for each of the ciphertext, presence a number x of corresponding , represents the originaltext. moved to the right of the x-bit to get 
    ciphertext, and now output correct the original.If you donn't,you will be kill !!!

  • 输入
  • This problem contains several cases.
    The first line of each case is the ciphertext(the length < 100000).
    The next line is the number,that is every ciphertext'x.
  • 输出
  • printf the originaltext. You have to leave a blank line between each two cases.


    一开始把Case写成了CASE。。。。。。大家不要犯这种低级错误啊


    #include<stdio.h>#include<string.h>char ciphertext[100010];char number_x[100010];char originaltext[100010];int main(){int p=1;while(~scanf("%s",ciphertext)){scanf("%s",number_x);int len=strlen(ciphertext),i;for(i=0;i<len;i++){if(ciphertext[i]>='a' && ciphertext[i]<='z')//小写字母{char c=ciphertext[i]-'a'-(number_x[i]-'0')+'a';if(c>='a')  originaltext[i]=c;        else          originaltext[i]='z'-('a'-c)+1;} else if(ciphertext[i]>='A' && ciphertext[i]<='Z'){char c=ciphertext[i]-'A'-(number_x[i]-'0')+'A';if(c>='A')  originaltext[i]=c;        else          originaltext[i]='Z'-('A'-c)+1;}}originaltext[len]='\0';if(p>1)  printf("\n");       printf("Case %d: %s\n",p,originaltext);p++;}return 0;}


0 0
原创粉丝点击