-
Notifications
You must be signed in to change notification settings - Fork 61
/
Pattern21.java
43 lines (43 loc) · 958 Bytes
/
Pattern21.java
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
38
39
40
41
42
43
package com.java.patterns;
import java.util.Scanner;
/*
Write the program to print the following pattern
A
C C C
E E E E E
G G G G G G G
I I I I I I I I I
*/
public class Pattern21 {
public static void main(String args[] ) throws Exception {
Scanner scanner = new Scanner(System.in);
int N = Integer.parseInt(scanner.nextLine());
String s = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int iSpace = 0;
int k = 0;
for(int i=0;i<N;i++){
for(int j = iSpace;j<N-1;j++)
System.out.print(" ");
for(int j=0;j<=k;j++)
if(j == 0)
System.out.print(s.charAt(k));
else
System.out.print(" "+s.charAt(k));
iSpace++;
k+=2;
if(i != N-1)
System.out.println();
}
scanner.close();
}
}
/*
Input
5
Output
A
C C C
E E E E E
G G G G G G G
I I I I I I I I I
*/