zoukankan      html  css  js  c++  java
  • Uva




    第一次不小心用printf输出WA了,还是要把输入输出统一起来,切记切记。题目不难,按路径算出叶子结点,最后统一输出就行了。

    AC代码:

    #include <iostream>
    #include <cstdio>
    #include <cstdlib>
    #include <cctype>
    #include <cstring>
    #include <string>
    #include <sstream>
    #include <vector>
    #include <set>
    #include <map>
    #include <algorithm>
    #include <stack>
    #include <queue>
    #include <bitset> 
    #include <cassert> 
    #include <cmath>
    
    using namespace std;
    
    const int maxn = 1000;
    int n, m, sum;
    string str[10], mstr[maxn]; // mstr存储操作的步骤
    char num[maxn]; // 结点的值
    
    int main()
    {
    	ios::sync_with_stdio(false);
    	int kase = 0;
    	while (cin >> n && n) {
    		sum = pow(2, n);
    		// 输入结点
    		for (int i = 0; i < n; i++) {
    			cin >> str[i];
    		}
    		cin >> num;
    
    		cin >> m;
    		int temp;
    		for (int i = 0; i < m; i++) {
    			cin >> mstr[i];
    		}
    		cout << "S-Tree #" << ++kase << ":
    ";
    		//printf("S-Tree #%d:
    ", ++kase);
    		for (int i = 0; i < m; i++) {
    			temp = 0;
    			for (int j = 0; j < n; j++) {
    				temp += (mstr[i][j] - '0') * pow(2, n - j - 1);
    			}
    			cout << num[temp];
    		}
    		cout << endl << endl;
    	}
    
    	return 0;
    }




  • 相关阅读:
    LIN总线学习-总线逻辑
    使用万用表测量CAN总线电压及实际电压与逻辑电瓶关系
    汽车网络和控制单元的安全威胁研究
    [CANopen] SDO的命令字
    新起点,新开始
    Git Commands
    Obsessive String
    The E-pang Palace
    最长递增子序列(LIS)
    Valid Sets
  • 原文地址:https://www.cnblogs.com/zhangyaoqi/p/4591543.html
Copyright © 2011-2022 走看看