Time Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other)
Total Submission(s) : 49 Accepted Submission(s) : 34
You are a sub captain of Caesar's army. It is your job to decipher the messages sent by Caesar and provide to your general. The code is simple. For each letter in a plaintext message, you shift it five places to the right to create the secure message (i.e., if the letter is 'A', the cipher text would be 'F'). Since you are creating plain text out of Caesar's messages, you will do the opposite:
Cipher text
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Plain text
V W X Y Z A B C D E F G H I J K L M N O P Q R S T U
Only letters are shifted in this cipher. Any non-alphabetical character should remain the same, and all alphabetical characters will be upper case.
#include<stdio.h>
#include<string.h>
void zhuanghua(char *a)//觀察可以從題目中發現規律,對輸入的字符串進行轉換
{
if(*a=='A')
*a='V';
else if(*a=='B')
*a='W';
else if(*a=='C')
*a='X';
else if(*a=='D')
*a='Y';
else if(*a=='E')
*a='Z';
else if(*a>'E' && *a<='Z')
*a=*a-5;
}
int main()
{
int i,j;
char a[1000],c[1000],b[1000];
while(gets(c))
{
if(strcmp(c,"ENDOFINPUT")==0)
break;
if(strcmp(c,"START")==0)
{
gets(a);
for(i=0;i<strlen(a);i++)
{
zhuanghua(&a[i]);
}
}
gets(b);
if(strcmp(b,"END")==0)
{
puts(a);
continue;
}
}
return 0;
}