-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStarDiamond.java
More file actions
32 lines (29 loc) · 805 Bytes
/
StarDiamond.java
File metadata and controls
32 lines (29 loc) · 805 Bytes
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
package com.CodeWithSarnav;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// write your code here
int i,j,k,n;
Scanner s=new Scanner(System.in);
System.out.print("Enter number of rows: ");
n=s.nextInt();
for(i=0;i<n-1;i++){
for(j=n-1;j>i;j--){
System.out.print(" ");
}
for(j=0;j<=i;j++){
System.out.print("* ");
}
System.out.println();
}
for(i=0;i<n;i++){
for(j=0;j<i;j++){
System.out.print(" ");
}
for(k=n-1;k>=i;k--){
System.out.print("* ");
}
System.out.println();
}
}
}