ITGUY100 - Editorial

Problem: Contest Page | CodeChef

DIFFICULTY:

EASY.

PROBLEM:

The chef is trying to solve some pattern problems, Chef wants your help to code it. Chef has one number K to form a new pattern. Help the chef to code this pattern problem.

Program:

#include<bits/stdc++.h>
using namespace std;
 
int main()
 {
	//code
	
	int t;
	cin>>t;
	while(t--){
		int n;
		cin>>n;
	    int x = n;
        for (int i = 1; i <= n; i++) {
            char ch = (char) (64 + i);
            int y = i;
            for (int j = 1; j <= 2 * n; j++) {
                if (j >= x && j <= n)
                    cout<<ch++;
                else if (j <= 2 * n - x + 1 && j > n)
                    cout<<y++;
                else
                    cout<<' ';
            }
            cout<<"\n";
            x--;
        }
	}
}