Source Code
#include <iostream>

using namespace std;

string part(int n) {
	if (n == 0)
		return "";

	string subPart = part(n - 1);
	string tmp = subPart;
	subPart += '\n';
	for (int i = 0; i < n; i++)
		subPart += "-";
	subPart += tmp;
	return subPart;
}

int main() {
	int L, P, tmp = 0;
	cin >> L >> P;
	string PART = part(P - 1);
	while (tmp < L) {
		for (int i = 0; i < P; i++) cout << "-";
		cout << tmp++;
		cout << PART << endl;
	}
	for (int i = 0; i < P; i++) cout << "-";
	cout << tmp++ << endl;



	return 0;
}
Copy
Ruler MohaDarkness
GNU G++17
3 ms
976 KB
Accepted