Source Code
#include <iostream>
using namespace std;

void print(int n){
	for(int i=0;i<n;i++){
		cout<<'-';
	}
	cout << endl<<"-"<<endl;
}
void half(int p){
	
	int x=2;
		while(x<=p-2){//cout<<"\nx = "<<x<<endl;
			print(p-(p-x));
			x++;
		}
		x--;
		while(x>1){
			x--;
			if(p-(p-x)!=1)
			print(p-(p-x));
		}
}

int main() {
	int l,p;
	cin>>l>>p;
	for(int out=0; out<=l;out++ ){
		for(int i = 0 ; i < p ; i++){
			cout<<'-';
		}
	cout << out<<endl;
		if(out!=l){
		cout<<"-\n";
		half(p);
		
		//you reached p-1
		for(int i=0;i<p-1;i++)
		{
			cout<<'-';
		}
		cout<<"\n-"<<endl;
		half(p);
		}
		//cout<<endl;
	}
	return 0;
}
Copy
Ruler Razanaws
GNU G++17
3 ms
732 KB
Wrong Answer