Source Code
#include <bits/stdc++.h>

using namespace std;
void print(int i){
    if( i == 1 ){
        cout << "-\n";
    } else if( i > 1) {
        print(i-1);
        cout << bars[i] << '\n';
        print(i-1);
    }
}

int main(){
    int l, p;
    cin >> l >> p;
    vector<string> bars;
    bars.resize(p+1, "");
    for(int i = 1; i <= p; ++i)
        bars[i] = bars[i-1] + '-';

    for(int i = 0; i < l; ++i){
        cout << bars[p] << i << '\n';
        print(p-1);
    }
    cout << bars[p] << l << endl;

	return 0;
}
Copy
Ruler Mohamedmaher
GNU G++17
0 ms
0 KB
Compilation Error