Problem: https://www.codechef.com/PBK12020/problems/ITGUY16
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()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int t;
cin >> t;
while (t--) {
int n, i, j;
cin >> n;
for (i = 1; i <= n; i++) {
char c = 'A';
int k = 1;
for (j = 1; j <= n; j++) {
if (j <= (n - i))
cout <<' ';
else {
if (i & 1)
cout << (c++);
else
cout << k++;
}
}
cout <<"\n";
}
}
return 0;
}