Program: 11
Program: 14
Program: 15
public class HelloWorld{ public static void main(String []args){ for(int i=1;i<=5;i++){ for(int k=1;k<i;k++) System.out.print(" "); for(int j=5;j>=i;j--){ System.out.print(j); } System.out.println(""); } } }Output:
5 4 3 2 1 5 4 3 2 5 4 3 5 4 5Program: 12
public class HelloWorld{ public static void main(String []args){ for(int i=1;i<=5;i++){ for(int k=5;k>i;k--) System.out.print(" "); for(int j=1;j<=i;j++){ System.out.print(i); } System.out.println(""); } } }Output:
1 2 2 3 3 3 4 4 4 4 5 5 5 5 5Program: 13
public class HelloWorld{ public static void main(String []args){ for(int i=1;i<=5;i++){ for(int k=5;k>i;k--) System.out.print(" "); for(int j=1;j<=i;j++){ System.out.print(j); } System.out.println(""); } } }Output:
1 1 2 1 2 3 1 2 3 4 1 2 3 4 5
Program: 14
public class HelloWorld{ public static void main(String []args){ for(int i=1;i<=10;i+=2){ for(int k=10;k>=i;k-=2) System.out.print(" "); for(int j=1;j<=i;j++){ System.out.print(j); } System.out.println(""); } } }Output:
1 1 2 3 1 2 3 4 5 1 2 3 4 5 6 7 1 2 3 4 5 6 7 8 9
Program: 15
public class HelloWorld{ public static void main(String []args){ for(int i=1;i<=10;i+=2){ for(int k=10;k>=i;k-=2) System.out.print(" "); for(int j=1;j<=i;j++){ System.out.print(i); } System.out.println(""); } } }Output:
1 3 3 3 5 5 5 5 5 7 7 7 7 7 7 7 9 9 9 9 9 9 9 9 9
No comments:
Post a Comment