#1948: a010 ans haha you don't need to see dominic's one he need 300人氣


1753980-3@g.puiching.edu.mo (P5A31蒲雋浠)

School : No School
ID : 2571
IP address : [192.168.120.33]
Last Login :
2025-03-20 12:13:05
a010. 聖經密碼 -- 板橋高中教學題 | From: [192.168.120.33] | Post Date : 2025-04-14 21:21

#include <iostream>
#include <vector>
#include <string>
using namespace std;

int main() {
    int n, m;
    while (cin >> n >> m && (n != 0 || m != 0)) {
        // 讀取所有單字並連接成一個長字串
        string concatenated;
        for (int i = 0; i < n; ++i) {
            string word;
            cin >> word;
            concatenated += word;
        }
        
        // 讀取查詢位置
        vector<int> positions(m);
        for (int i = 0; i < m; ++i) {
            cin >> positions[i];
        }
        
        // 構建結果字串
        string result;
        for (int pos : positions) {
            // 注意題目中的位置是從1開始的
            result += concatenated[pos - 1];
        }
        
        cout << result << endl;
    }
    return 0;
}
 
#1950: Re:a010 ans haha you don't need to see dominic's one he need 300人氣


1753422-4@g.puiching.edu.mo (P5A30廖善衡)

School : No School
ID : 2950
IP address : [192.168.120.33]
Last Login :
2025-03-20 11:41:41
a010. 聖經密碼 -- 板橋高中教學題 | From: [192.168.120.33] | Post Date : 2025-04-14 21:30

#include 
#include 
#include 
using namespace std;

int main() {
    int n, m;
    while (cin >> n >> m && (n != 0 || m != 0)) {
        // 讀取所有單字並連接成一個長字串
        string concatenated;
        for (int i = 0; i < n; ++i) {
            string word;
            cin >> word;
            concatenated += word;
        }
        
        // 讀取查詢位置
        vector positions(m);
        for (int i = 0; i < m; ++i) {
            cin >> positions[i];
        }
        
        // 構建結果字串
        string result;
        for (int pos : positions) {
            // 注意題目中的位置是從1開始的
            result += concatenated[pos - 1];
        }
        
        cout << result << endl;
    }
    return 0;
}

are you using ai

 
ZeroJudge Forum