Summing up the topic of the law, if the input is x1,x2,x3, then X1 corresponding weights for the 4,x2 corresponding weights for the 2,x3 corresponding weights are 1, the other input and so on, are based on 2 values. For subsequent input to be judged, the corresponding values are computed, which is the position in the array, locating the element by position and outputting the line. The specific implementation see source code:
#include <iostream> #include <vector> #include <string> #include <set> #include <stack> # include<queue> #include <map> #include <algorithm> #include <cmath> #include <iomanip> #
include<cstring> #include <sstream> #include <cstdio> using namespace std;
int n;
int main () {int amount = 0;
while (CIN >> N) {amount++;
if (n = = 0) break;
Vector<int> order;
for (int i = 0; i < n; i++) {string S;
Cin >> S;
int index = 0;
for (int j = 1; J < S.size (); j + +) {index = index * + (s[j]-' 0 ');
} order.push_back (index);
} string data;
CIN >> data;
int m;
Cin >> m;
vector<char> result;
for (int i = 0; i < m; i++) {string D;
Cin >> D;
int index = 0;
for (int j = 0; J < Order.size (); j + +) {index = index * 2 + (d[order[j]-1]-' 0 ');
} result.push_back (Data[index]); } cout << "S-tree #" <<amount<< ": "<< Endl;
for (int i = 0; i < result.size (); i++) cout << result[i];
cout << Endl << Endl;
return 0; }