Source Code
#include <iostream>
using namespace std;
string calc( int a ){
	if ( a == 1 ) return "-\n" ;
	string s = "" ;
	for ( int i = 0 ; i < a ; i++ )  {
		s += '-' ;
	}
	s += "\n" ;
	string b = calc(a-1);
	return b+s+b ;
}
int main() {
	int l , p;
	cin >> l >> p;
	for ( int i = 0 ; i <= l ; i++ ) {
		for(int j=0;j<p;j++)cout << '-' ;
		cout << i << endl ;
		if(i==l)continue;
		cout << calc(p-1);
	}
	return 0;
}
Copy
Ruler SAAD
GNU G++17
177 ms
262.1 MB
Memory Limit Exceeded