PROBLEM LINK:
Author: Vidya kale
Tester: Vidya kale
Editorialist: Vidya kale
DIFFICULTY:
CAKEWALK.
PREREQUISITES:
None.
PROBLEM:
Everyone knows the pyramid . But ram wants to display the pattern like a pyramid with a number which will repeat the number in the same row . i.e. If N is number of rows , then print N number rows of pyramid …
QUICK EXPLANATION:
print the pyramid with number which will repeat the number in the same row.
EXPLANATION:
Display the pattern like a pyramid with a number which will repeat the number in the same row
SOLUTIONS:
Setter's Solution
#include <iostream>
using namespace std;
int main()
{
int rows,t,k;
cin>>t;
for(k=0;k<t;k++){
cin >> rows;
for (int i = 1; i <= rows; i++)
{
for (int j = rows; j > i; j--)
{
cout << " ";
}
for (int k = 1; k <= i; k++)
{
cout << i << " ";
}
cout << "\n";
}
}
}
Tester's Solution
#include <iostream>
using namespace std;
int main()
{
int rows,t,k;
cin>>t;
for(k=0;k<t;k++){
cin >> rows;
for (int i = 1; i <= rows; i++)
{
for (int j = rows; j > i; j--)
{
cout << " ";
}
for (int k = 1; k <= i; k++)
{
cout << i << " ";
}
cout << "\n";
}
}
}
Editorialist's Solution
#include <iostream>
using namespace std;
int main()
{
int rows,t,k;
cin>>t;
for(k=0;k<t;k++){
cin >> rows;
for (int i = 1; i <= rows; i++)
{
for (int j = rows; j > i; j--)
{
cout << " ";
}
for (int k = 1; k <= i; k++)
{
cout << i << " ";
}
cout << "\n";
}
}
}