Author: noob_tech
Tester: noob_tech
Editorialist: noob_tech
DIFFICULTY:
SIMPLE.
PROBLEM:
CodeMaster is trying to solve pattern problem. CodeMaster has given N to create a pattern. Help the CodeMaster to code this pattern problem.
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 << “_”;
if (j < i - 1)
{
cout << " ";
}
}
for (int j = 1; j < i; j++)
{
cout << ch++;
}
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 << “_”;
if (j < i - 1)
{
cout << " ";
}
}
for (int j = 1; j < i; j++)
{
cout << ch++;
}
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 << “_”;
if (j < i - 1)
{
cout << " ";
}
}
for (int j = 1; j < i; j++)
{
cout << ch++;
}
cout << endl;
}
}
return 0;
}