# Pattern02(https://www.codechef.com/CBST2021/problems/PATT02)

Practice

Author: noob_tech
Tester: noob_tech
Editorialist: noob_tech

# DIFFICULTY:

CAKEWALK, SIMPLE, EASY.

Math .

# PROBLEM:

CodeMaster is trying to solve pattern problem. Codemaster has given N to create a pattern. Help the CodeMaster to code this pattern problem.

# QUICK EXPLANATION:

Just observe the pattern and print them.

# SOLUTIONS:

Setter's Solution

#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin >> t;
while (t–)
{
char ch = ‘A’;
int n;
cin >> n;
cout << " * " << ch++ << endl;
for (int i = 2; i <= n; i++)
{
for (int j = 1; j < i; j++)
{
cout << " * ";
}
cout << " * ";
for (int j = 1; j < i; j++)
{
cout << " * ";
}
for (int j = 1; j < i; j++)
{
cout << ch++;
}
for (int j = 1; j < i; j++)
{
cout << ch++;
}
for (int j = 1; j < i; j++)
{
cout << " * ";
}
for (int j = 1; j < i; j++)
{
cout << " * ";
}
cout << endl;
}
}
return 0;
}

Tester's Solution

#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin >> t;
while (t–)
{
char ch = ‘A’;
int n;
cin >> n;
cout << " * " << ch++ << endl;
for (int i = 2; i <= n; i++)
{
for (int j = 1; j < i; j++)
{
cout << " * ";
}
cout << " * ";
for (int j = 1; j < i; j++)
{
cout << " * ";
}
for (int j = 1; j < i; j++)
{
cout << ch++;
}
for (int j = 1; j < i; j++)
{
cout << ch++;
}
for (int j = 1; j < i; j++)
{
cout << " * ";
}
for (int j = 1; j < i; j++)
{
cout << " * ";
}
cout << endl;
}
}
return 0;
}

Editorialist's Solution

#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin >> t;
while (t–)
{
char ch = ‘A’;
int n;
cin >> n;
cout << " * " << ch++ << endl;
for (int i = 2; i <= n; i++)
{
for (int j = 1; j < i; j++)
{
cout << " * ";
}
cout << " * ";
for (int j = 1; j < i; j++)
{
cout << " * ";
}
for (int j = 1; j < i; j++)
{
cout << ch++;
}
for (int j = 1; j < i; j++)
{
cout << ch++;
}
for (int j = 1; j < i; j++)
{
cout << " * ";
}
for (int j = 1; j < i; j++)
{
cout << " * ";
}
cout << endl;
}
}
return 0;
}