Hollow Diamond
Write a program to take number n and print a Hollow Diamond shape .
Input Format:
Take an Integer from stdin.
Output:
Print the desired Pattern
Example Input:
5
Output:
*
* *
* *
* *
* *
* *
* *
* *
*
Solution:
n=int(input())
a=(n*2)-1 #no of lines
for i in range(a):
for j in range(a):
if(i+j==int(a/2) or j-i==int(a/2) or i-j==int(a/2) or i+j==((a-1)+int(a/2))):
print("*",end="")
else:
print(" ",end="")
print("")
Comments
Post a Comment