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

UVA 712 S-Trees

时间:2014-07-22 22:35:35      阅读:185      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   os   io   for   

二叉树? 怒水~~

注意一下查询与x值的对应关系就好~

 

 

 1 #include <iostream>
 2 #include <cstring>
 3 #include <cstdio>
 4 using namespace std;
 5 
 6 int main (){
 7     char s[1000];
 8     int a[10],b[10];
 9     int n;
10     int m;
11     int kase=0;
12     while (~scanf ("%d",&n)&&n){
13         char c[10];
14         for (int i=0;i<n;i++){
15             scanf ("%s",c);
16             a[i]=c[1]-0;//cout<<a[i]<<"eee";
17         }
18         scanf ("%s",s);
19         scanf ("%d",&m);
20         printf ("S-Tree #%d:\n",++kase);
21         for (int i=0;i<m;i++){
22             scanf ("%s",c);
23             int temp=0;
24             for (int j=0;j<n;j++){
25                 b[j]=c[a[j]-1]-0;
26                 temp=temp*2+b[j];
27             }
28             printf ("%c",s[temp]);//cout<<temp<<"er"<<endl;
29         }
30         printf ("\n\n");
31     }
32     return 0;
33 }

UVA 712 S-Trees,布布扣,bubuko.com

UVA 712 S-Trees

标签:style   blog   color   os   io   for   

原文地址:http://www.cnblogs.com/gfc-g/p/3860833.html

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