原题:
Description
密码字母: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 M
原文字母: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
注意:只有字母会发生替换,其他非字母的字符不变,并且消息原文的所有字母都是大写的。
Input
- 起始行:START
- 密码消息:由1到200个字符组成一行,表示凯撒发出的一条消息.
- 结束行:END
在最后一个数据集之后,是另一行:ENDOFINPUT
Output
Sample Input
START NS BFW, JAJSYX TK NRUTWYFSHJ FWJ YMJ WJXZQY TK YWNANFQ HFZXJX END START N BTZQI WFYMJW GJ KNWXY NS F QNYYQJ NGJWNFS ANQQFLJ YMFS XJHTSI NS WTRJ END START IFSLJW PSTBX KZQQ BJQQ YMFY HFJXFW NX RTWJ IFSLJWTZX YMFS MJ END ENDOFINPUT
Sample Output
IN WAR, EVENTS OF IMPORTANCE ARE THE RESULT OF TRIVIAL CAUSES I WOULD RATHER BE FIRST IN A LITTLE IBERIAN VILLAGE THAN SECOND IN ROME DANGER KNOWS FULL WELL THAT CAESAR IS MORE DANGEROUS THAN HE
分析:字符串水题~
原码:
#include<stdio.h> #include<string.h> char map[]="VWXYZABCDEFGHIJKLMNOPQRSTU"; int main() { char s[101]; int i,j=10; while(1) { gets(s); if(strcmp(s,"ENDOFINPUT")==0) break; gets(s); for(i=0; s[i]!='\0'; i++) { if(s[i]>='A'&&s[i]<='Z') printf("%c",map[s[i]-'A']); else printf("%c",s[i]); } gets(s); printf("\n"); } return 0; }