Computer Science, asked by aishwaryasangade1, 9 months ago

Write a program to print the following pattern.
Sample Input:
5
Sample Output:
1
2*2
3*3*3
4*4*4*4
5*5*5*5*5
5*5*5*5*5
4*4*4*4
3*3*3
2*2
1

Answers

Answered by anagasatyasri710
8

Answer:

#include<iostream>

using namespace std;

int main()

{

 int i,j,n;

 cin>>n;

 for(i=1;i<=n;i++){

   for(j=1;j<=i;j++){

     if(j<i)

       cout<<i<<"*";

     else

       cout<<i;

   }

   cout<<"\n";

 }

 for(i=n;i>=1;i--){

   for(j=1;j<=i;j++){

     if(j<i)

       cout<<i<<"*";

     else

       cout<<i;

   }

   cout<<"\n";

 }

 return 0;

}

Answered by poojan
6

Python program to solve Numerical Belly problem:

Language using: Python Programming

Program:

n=int(input())

l=[]

t=''

for i in range(1,n+1):

   y=''

  y=y+str(i)             #initial number of the row

   print(y,end='')

   m=''

   for j in range(1,i):    #for the remaining row fill following the 1st number

       m=m+'*'+str(i)

       print('*'+str(i),end='')

   print(end='\n')

   l.append(y+m)       #for the second half of diamond fill

for i in l[::-1]:       #As we need to start from 55555, we are reversing the list

   print(i)

Testcases:

Input1:

1

Output1:

1

1

Input2:

2

Output2:

1

2*2

2*2

1

Input3:

3

Output3:

1

2*2

3*3*3

3*3*3

2*2

1

Input4:

5

Output4:

1

2*2

3*3*3

4*4*4*4

5*5*5*5*5

5*5*5*5*5

4*4*4*4

3*3*3

2*2

1

Learn more:

Write a Python function sumsquare(l) that takes a nonempty list of integers and returns a list [odd,even], where odd is the sum of squares all the odd numbers in l and even is the sum of squares of all the even numbers in l

brainly.in/question/15473120

Python program to find absolute difference between the odd and even numbers in the inputted number.

brainly.in/question/11611140

Similar questions