Given an integer N
as the input print the pattern as given in the Example Input/Output section.
Input
Format:
The first line
contains N.
Output
Format:
2N lines
containing the desired pattern.
Boundary
Conditions: 2 <= N <= 50
Example
Input/Output:
Input:
4
Output:
1
2*2
3*3*3
4*4*4*4
4*4*4*4
3*3*3
2*2
1
Solution:
#include
<iostream>
using namespace
std;
int main()
{
int i,j,n,k;
cin>>n;
for(i=1;i<=2*n;i++)
{
k=i>n?(2*n-i)+1:i;
for(j=1;j<=k;j++)
{
cout<<k;
if(j!=k) cout<<"*";
}
cout<<endl;
}
return 0;
}