Source Code
#include<iostream>
#include<math.h>
using namespace std;

int arr[10];


void print(int t) {
	for (int i = 0; i < t; i++)
		cout << "-";
	cout << endl;
}

int main() {
	arr[2] = 0;
	arr[3] = 1;
	arr[4] = 3;
	arr[5] = 5;
	arr[6] = 7;
	arr[7] = 9;
	arr[8] = 11;
	arr[9] = 13;
	int p, l;
	cin >> l;
	cin >> p;
	int t = 3;
	bool flag = false;
	int c = 1;

	for (int i = 0; i < l; i++) {
		c++;
		t = 3;
		flag = false;
		for (int r = 0; r < p; r++) cout << '-';
		cout << i << endl;
		if (p > 2) {
			for (int j = 0; j < arr[p - 1]; j++) {
				cout << "-" << endl << "--" << endl << "-" << endl;
				print(t);
				if (t == p - 1)
					flag = true;

				if (flag == true) t--;
				else t++;


			}

			cout << "-" << endl << "--" << endl << "-" << endl;
		}
		else if (p == 2) {
			cout << "-" << endl;
		}
	}

	for (int r = 0; r < p; r++) cout << '-';
	cout << l;

}
Copy
Ruler salem
GNU G++17
3 ms
860 KB
Wrong Answer