-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
166d7d9
commit ec5e2f8
Showing
1 changed file
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import java.io.*; | ||
import java.util.*; | ||
|
||
public class Pattern2 { | ||
|
||
public static void main(String []args) | ||
{ | ||
Scanner scanner = new Scanner(System.in); | ||
int n = scanner.nextInt(); //n | ||
int start=10; | ||
int end = n*(n+1)*10;// 120 | ||
int values, spaces, ctr; | ||
|
||
for(int i =0; i<n; i++) | ||
{ | ||
values = 2*n -(2*i); // | ||
spaces = 2*n-values; | ||
ctr = values/2; | ||
|
||
while(spaces>0) | ||
{ | ||
System.out.print("*"); | ||
spaces--; | ||
} | ||
|
||
int j =ctr; | ||
|
||
while(j>0) | ||
{ | ||
System.out.print(start); | ||
j--; | ||
start+=10; | ||
} | ||
|
||
j =ctr; | ||
end = end - ((j-1)*10); | ||
|
||
while(j>1) | ||
{ | ||
System.out.print(end); | ||
j--; | ||
end+=10; | ||
} | ||
System.out.print(end/10); | ||
|
||
end = end - (ctr*10); | ||
|
||
System.out.println(" "); | ||
} | ||
|
||
|
||
|
||
} | ||
|
||
} |