View Code of Problem 125

#include <bits/stdc++.h>
using namespace std;
int n,m;
const char c1 = '-';
const char c2 = '|';
int main()
{
	cin>>n;
	for(int i=0;i<2*n+3;i++) {
		if(i%(n+1)==0) {
			cout<<" ";
			for(int j=0;j<n;j++) {
				cout<<c1;
			}
			if(i!=2*n+2)
				cout<<" "<<endl;	
		} else {
			for(int j=0;j<n+2;j++) {
				if(j==0||j==n+1)
					cout<<c2;
				else 
					cout<<" ";
			}
			cout<<endl;	
		}
		
		
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 125