码迷,mamicode.com
首页 > 其他好文 > 详细

POJ 2608

时间:2014-06-04 17:03:39      阅读:195      评论:0      收藏:0      [点我收藏+]

标签:c   style   class   blog   code   a   

bubuko.com,布布扣
 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

 

POJ 2608,布布扣,bubuko.com

POJ 2608

标签:c   style   class   blog   code   a   

原文地址:http://www.cnblogs.com/jie-dcai/p/3764696.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!