Pattern01(https://www.codechef.com/CBST2021/problems/PATT01)

Practice

Author: noob_tech
Tester: noob_tech
Editorialist: noob_tech

DIFFICULTY:

SIMPLE,.

PREREQUISITES:

Pattern Problem.

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:

Obesrve the pattern and print it.

SOLUTIONS:

Setter's Solution

#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin >> t;
while (t- -)
{
char ch = ‘A’;
int k = 65;
int n;
cin >> n;
cout << ch << k << endl;
for (int i = 2; i <= n; i++)
{
for (int j = 1; j < i; j++)
{
cout << " ";
}
for (int j = 1; j < i; j++)
{
cout << ch;
}
cout << “B”;
for (int j = 1; j < i; j++)
{
cout << ch;
}
for (int j = 1; j < i; j++)
{
cout << “65”;
}
cout << “66”;
for (int j = 1; j < i; j++)
{
cout << “65”;
}
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 k = 65;
int n;
cin >> n;
cout << ch << k << endl;
for (int i = 2; i <= n; i++)
{
for (int j = 1; j < i; j++)
{
cout << " ";
}
for (int j = 1; j < i; j++)
{
cout << ch;
}
cout << “B”;
for (int j = 1; j < i; j++)
{
cout << ch;
}
for (int j = 1; j < i; j++)
{
cout << “65”;
}
cout << “66”;
for (int j = 1; j < i; j++)
{
cout << “65”;
}
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 k = 65;
int n;
cin >> n;
cout << ch << k << endl;
for (int i = 2; i <= n; i++)
{
for (int j = 1; j < i; j++)
{
cout << " ";
}
for (int j = 1; j < i; j++)
{
cout << ch;
}
cout << “B”;
for (int j = 1; j < i; j++)
{
cout << ch;
}
for (int j = 1; j < i; j++)
{
cout << “65”;
}
cout << “66”;
for (int j = 1; j < i; j++)
{
cout << “65”;
}
cout << endl;
}
}
return 0;
}