POJ 2608

 1 #include <iostream>
 2 #include <cstdio>
 3 #include <string.h>
 4 using namespace std;
 5 int a[30]={-1,1,2,3,-1,1,2,-1,-1,2,2,4,5,5,-1,1,2,6,2,3,-1,1,-1,2,-1,2};
 6 char s[25]; int ans[25];
 7 int main(){
 8     while(scanf("%s",s)!=EOF){
 9         int len=strlen(s); int top=-1; bool flag=false;
10         for(int i=0;i<len;i++)
11         if(a[s[i]-'A']>0){
12             if(top==-1||ans[top]!=a[s[i]-'A']||flag){
13             ans[++top]=a[s[i]-'A'];
14             flag=false;
15             }
16         }
17         else flag=true;
18         for(int i=0;i<=top;i++)
19         printf("%d",ans[i]);
20         printf("\n");
21     }
22     return 0;
23 }
View Code

 

posted @ 2014-06-02 21:14  chenjunjie1994  阅读(106)  评论(0编辑  收藏  举报