HDU1048

字符串处理的简单题

View Code
 1 /*
 2 字符串处理 简单
 3 */
 4 #include<stdio.h>
 5 #include<stdlib.h>
 6 #include<string.h>
 7 #include<iostream>
 8 #include<algorithm>
 9 #include<queue>
10 #include<map>
11 #include<math.h>
12 using namespace std;
13 const int maxn = 305;
14 const int inf = 0x7fffffff;
15 char s[ maxn ],tmp[ maxn ];
16 char solve( char ch ){
17     if( ch>='F' ) return ch-5;
18     if( ch=='E' ) return 'Z';
19     if( ch=='D' ) return 'Y';
20     if( ch=='C' ) return 'X';
21     if( ch=='B' ) return 'W';
22     if( ch=='A' ) return 'V';
23 }
24 int main(){
25     while( scanf("%s",tmp)!=EOF && strcmp(tmp,"ENDOFINPUT")!=0 ){
26         getchar();
27         gets(s);//scanf("%s",s);
28         //printf("\ns:%s\n",s);
29         scanf("%s",tmp);
30         int len=strlen( s );
31         for( int i=0;i<len;i++ ){
32             if( s[ i ]>='A' && s[ i ]<='Z' ) printf("%c",solve( s[i] ));
33             else printf("%c",s[i]);
34         }
35         printf("\n");
36     }
37     return 0;
38 }
keep moving...
原文地址:https://www.cnblogs.com/xxx0624/p/2809198.html