Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
805 B
3
Indexable
Never
#include <iostream>
using namespace std;

/*
N 商品要買
K 層樓
每層有Bi個商品
*/

/*
6
8 5 9 12 0 6
2
3 5 9 12
2 6 8
*/

int main() {
    int n, k;
    int* arr_A;
    int* arr_B;
    // arr_B 待會指向k個int, 每個int表示第i層樓有Bi個商品
    int** arr_C;
    // arr_C 待會指向k個int*, 每個int*待會會被配置到Bi個int格子

    // 存A_i

    // 存每層樓幾個商品Bi & 存第i層樓的第j個商品Cij

    cout << "想買的: " << endl;
    for (int i = 0; i < n; i++) {
        cout << arr_A[i] << " ";
    }
    cout << endl;

    cout << "商品們: " << endl;
    for (int i = 0; i < k; i++) {
        int b = arr_B[i];
        for (int j = 0; j < b; j++) {
            cout << arr_C[i][j] << " ";
        }
        cout << endl;
    }


    return 0;
}
Leave a Comment