uva 712

#include <iostream>
using namespace std;
#include <string>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>

char rec[150][10];
int i;
int sum1[150];

void solve() {
int j = 0;
int t = 0, k = 0, sum = 0, p = 0;
char c;

for (j = 0; j < i ; j++){
sum = 0;
k = 0;

for (t = strlen(rec[j])-1; t >= 0; t--){
int h = rec[j][t] - 48;
sum = sum + h * pow(2, k++);
}
sum1[p++] = sum;
}

}

int main() {
int n, m, flag = 0;
char s[30], leafs[150];

while (scanf("%d", &n) && n) {

getchar();
gets(s);
scanf("%s", leafs);
scanf("%d", &m);

i = 0;
flag++;
memset(rec, '\0', 150 * 10 * sizeof(char));

while (m--) {
scanf("%s", rec[i++]);
}
solve();

printf("S-Tree #%d:\n", flag);
for (int q = 0; q < i; q++)
printf("%c", leafs[sum1[q]]);
printf("\n\n");
}

return 0;

}

算法入门经典习题6-2，uva712，S-Trees

2016-04-21 23:44:05

uva 712 - S-Trees

2012-07-19 17:52:10

UVA712

2014-07-24 21:51:06

UVa 712 S树

2014-08-27 20:35:57

Uva - 712 - S-Trees

2015-06-18 19:38:19

uva712

2016-01-21 14:11:29

UVa 769 - Magic of David Copperfield 解题报告（思维）

2014-07-28 23:35:40

uva712 -- S-Trees

2017-04-16 12:47:12

uva - 712

2015-08-01 10:48:33

UVa 712

2015-10-01 10:14:38

uva 712