Skip to content

Commit

Permalink
pattern module
Browse files Browse the repository at this point in the history
5 questions of patterns completed InnogeeksOrganization#155
  • Loading branch information
seriouslyanuj committed Oct 20, 2022
1 parent 5357054 commit 16ddc08
Show file tree
Hide file tree
Showing 5 changed files with 118 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import java.util.Scanner;

public class Main {

public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();

for (int i = 1; i <= n; i++) {
for (int j = 1; j <= i; j++) {
System.out.print("*\t");
}
System.out.println();
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import java.util.Scanner;

public class Main {

public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();

int nstars = n;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= nstars; j++) {
System.out.print("*\t");
}
nstars--;
System.out.println();
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import java.util.Scanner;

public class Main {

public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();

int nspaces = n - 1;
int nstars = 1;

for (int i = 1; i <= n; i++) {
for (int j = 1; j <= nspaces; j++) {
System.out.print("\t");
}

for (int j = 1; j <= nstars; j++) {
System.out.print("*\t");
}

nspaces--;
nstars++;
System.out.println();
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import java.util.Scanner;

public class Main {

public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int spaces = 0;
int stars = n;
for(int i = 1; i <= n; i++){
for(int j = 1; j <= spaces; j++){
System.out.print("\t");
}
for(int j = 1; j <= stars; j++){
System.out.print("*\t");
}
System.out.println();
spaces++;
stars--;
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import java.util.Scanner;

public class Main {

public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();

int nspaces = n / 2;
int nstars = 1;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= nspaces; j++) {
System.out.print("\t");
}

for (int j = 1; j <= nstars; j++) {
System.out.print("*\t");
}

if (i <= n / 2) {
nspaces--;
nstars += 2;
} else {
nspaces++;
nstars -= 2;
}

System.out.println();
}

}
}

0 comments on commit 16ddc08

Please sign in to comment.