#include <stdio.h>
int main()
{
int test, n, i, sum, nt = 0;
char num[130] = {0};
int x[8];
char vva[8];
while (scanf("%d", &test), test) {
for (i = 0; i < test; i++)
scanf("\nx%d", &x[i]);
scanf("%s", num);
scanf("%d", &n);
printf("S-Tree #%d:\n", ++nt);
while (n--) {
scanf("%s", vva);
// 将vva转换为十进制sum, num[sum]就是VVA的值
for (i = sum = 0; i < test; i++) {
sum = sum * 2 + (vva[x[i]-1] - '0');
}
printf("%c", num[sum]);
}
printf("\n\n");
}
}
POJ-1105
最新推荐文章于 2020-07-29 21:54:12 发布