Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
print alphabets using stars
//'main' method must be in a class 'Rextester'. //Compiler version 1.8.0_111 import java.util.Scanner; class Rextester { public static void main(String[] nick) { Scanner in=new Scanner(System.in); int n; n=in.nextInt(); for(int i=1;i<=n;i++) { System.out.print("*"); for(int j=1;j<i;j++) System.out.print(" "); System.out.println("*"); } for(int i=2;i<=n;i++) { System.out.print("*"); for(int j=1;j<=n-i;j++) System.out.print(" "); System.out.println("*"); } for(int i=1;i<=n;i++) System.out.println("*"); System.out.println("\n"); for(int i=1;i<=n;i++) { System.out.print("*"); for(int j=1;j<i;j++) System.out.print(" "); System.out.println("*"); } for(int i=2;i<=n;i++) { System.out.print("*"); for(int j=1;j<=n-i;j++) System.out.print(" "); System.out.println("*"); } for(int i=1;i<=n;i++) { System.out.print("*"); for(int j=1;j<=i;j++) System.out.print(" "); System.out.println("*"); } for(int i=2;i<=n;i++) { System.out.print("*"); for(int j=1;j<=n-i;j++) System.out.print(" "); System.out.println("*"); } System.out.println("\n"); for(int i=1;i<=n;i++) { System.out.print("*"); for(int j=1;j<i;j++) System.out.print(" "); System.out.println("*"); } for(int i=2;i<=n;i++) { System.out.print("*"); for(int j=1;j<=n-i;j++) System.out.print(" "); System.out.println("*"); } for(int i=1;i<=n;i++) System.out.println("*"); } }
run
|
edit
|
history
|
help
0
Meena
pk3
test1
First Interview question - Java
Array - char
call para cons
Test processing time (loop vs. contains)
forloop
Java # Dizi ile ek bulma
How many Squares in Rectangle