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){
			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;
	if(p==1){
		for(int out=0; out<=l;out++ ){
		for(int i = 0 ; i < p ; i++){
			cout<<'-';
		}
		
		cout<<out<<endl;
		}
		return 0 ;
	}

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