forked from jvm-coder/Java_Programs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnumber_diamond.java
More file actions
37 lines (31 loc) · 1.07 KB
/
number_diamond.java
File metadata and controls
37 lines (31 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import java.util.Scanner;
public class diamond_pattern
{
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
System.out.println("Enter number of rows");
int n = sc.nextInt();
System.out.println("Enter number of colums");
int m = sc.nextInt();
for (int i = 1; i <= n; i++)
{
//n = 4;
for (int j = 1; j<= n - i; j++) { System.out.print(" "); } for (int k = i; k >= 1; k--)
{
System.out.print(k);
}
for (int l = 2; l <= i; l++) { System.out.print(l); } System.out.println(); } for (int i = 3; i >= 1; i--)
{
n = 3;
for (int j = 0; j<= n - i; j++) { System.out.print(" "); } for (int k = i; k >= 1; k--)
{
System.out.print(k);
}
for (int l = 2; l <= i; l++)
{
System.out.print(l);
}
System.out.println();
}
}
}