MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / Codechef3

Class Codechef3

Java/PatternQuestions/Question15.java:3–31  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1import java.io.IOException;
2import java.io.*;
3public class Codechef3 {
4 public static void main(String[] args) throws IOException{
5 BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
6 int n = Integer.parseInt(br.readLine());
7 for (int row = 0; row < n; row++) {
8 for (int spaces = n; spaces > row; spaces--) {
9 System.out.print(" ");
10 }
11 if(row%2!=0){
12 for (int i = 0; i <= row; i++) {
13 if (i%2!=0 || i != 1) {
14 if(i == 0 || i == row){
15 System.out.print("* ");
16 }
17 else{
18 System.out.print(" ");
19 }
20 }
21 }
22 }
23 else{
24 for (int i = 0; i <= row; i++) {
25 System.out.print("* ");
26 }
27 }
28 System.out.println();
29 }
30 }
31 }

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected