Author: Sachin Singh
Tester: Sachin Singh
Editorialist: Sachin Singh
DIFFICULTY:
EASY.
PROBLEM:
CodeMaster is trying to solve pattern problem. Help the codeMaster to solve this pattern.
SOLUTIONS:
Setter's Solution
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t–)
{
int n;
cin>>n;
cout<<“1”<<endl;
int i=2;
for(i=2;i<=n;i++)
{
int j=1;
while(j<i)
{
cout<<j;
int l=j;
while(l–)
{
cout<<“*”;
}
j++;
}
cout<<j<<endl;
}
}
return 0;
}
Tester's Solution
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t–)
{
int n;
cin>>n;
cout<<“1”<<endl;
int i=2;
for(i=2;i<=n;i++)
{
int j=1;
while(j<i)
{
cout<<j;
int l=j;
while(l–)
{
cout<<“*”;
}
j++;
}
cout<<j<<endl;
}
}
return 0;
}
Editorialist's Solution
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t–)
{
int n;
cin>>n;
cout<<“1”<<endl;
int i=2;
for(i=2;i<=n;i++)
{
int j=1;
while(j<i)
{
cout<<j;
int l=j;
while(l–)
{
cout<<“*”;
}
j++;
}
cout<<j<<endl;
}
}
return 0;
}