freetimestudys@gmail.com          +91-7097633380
  Login Here                        

pattern

import java.util.Scanner;
public class Test
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);

System.out.println("How Many Rows You Want In Your Diamond?");
int n= sc.nextInt();
int m= n/2;
int row = 1;
for (int i = m; i > 0; i--)
{
for (int j = 1; j <= i; j++)
{
System.out.print(" ");
}
for (int j = 1; j <= row; j++)
{
System.out.print(row+" ");
}
System.out.println();
row++;
}
for (int i = 0; i <= m; i++)
{
for (int j = 1; j <= i; j++)
{
System.out.print(" ");
}
for (int j = row; j > 0; j--)
{
System.out.print(row+" ");
}
System.out.println();
row--;
}
}
}

intput and output

How Many Rows You Want In Your Diamond?
7
1
2 2
3 3 3
4 4 4 4
3 3 3
2 2
1