Program: 21
Output:
Program: 22
Output:public class HelloWorld{ public static void main(String []args){ for(int i=11;i>=1;i--){ for(int j=1;j<10;j++){ if((j<(2+((11/2)-(i)))) || (j>=(11-((11/2)-(i-2))))) System.out.print(j); else System.out.print(" "); } System.out.println(""); } } }
Output:
1 9 1 2 8 9 1 2 3 7 8 9 1 2 3 4 6 7 8 9 1 2 3 4 5 6 7 8 9
Program: 22
public class HelloWorld{ public static void main(String []args){ for(int i=1;i<10;i++){ for(int j=1;j<10;j++){ if((j<(2+((11/2)-(i)))) || (j>=(11-((11/2)-(i-2)))) || (j<=(1+(i-(11/2)))) || (j>=(9-(i-(11/2))))) System.out.print(i); else{ System.out.print(" "); } } System.out.println(""); } } }
1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 3 3 3 3 3 3 4 4 4 4 5 5 6 6 6 6 7 7 7 7 7 7 8 8 8 8 8 8 8 8 9 9 9 9 9 9 9 9 9
Program: 23
public class HelloWorld{ public static void main(String []args){ for(int i=1;i<10;i++){ for(int j=1;j<10;j++){ if((j<(2+((11/2)-(i)))) || (j>=(11-((11/2)-(i-2)))) || (j<=(1+(i-(11/2)))) || (j>=(9-(i-(11/2))))) System.out.print(j); else{ System.out.print(" "); } } System.out.println(""); } } }
Output:
1 2 3 4 5 6 7 8 9 1 2 3 4 6 7 8 9 1 2 3 7 8 9 1 2 8 9 1 9 1 2 8 9 1 2 3 7 8 9 1 2 3 4 6 7 8 9 1 2 3 4 5 6 7 8 9
Program: 24
public class HelloWorld{ public static void main(String []args){ for(int i=0;i<11;i++){ for(int j=0;j<10;j++){ if((j<(0+((11/2)-(i)))) || (j>=(11-((11/2)-(i-2)))) || (j<=(1+(i-(11/2)))) || (j>=(7-(i-(11/2))))) System.out.print(" "); else{ System.out.print(i); } } System.out.println(""); } } }
Output:
1 2 2 2 3 3 3 3 3 4 4 4 4 4 4 4 5 5 5 5 5 6 6 6 7
Program: 25
public class HelloWorld{ public static void main(String []args){ for(int i=0;i<11;i++){ for(int j=0;j<10;j++){ if((j<(0+((11/2)-(i)))) || (j>=(11-((11/2)-(i-2)))) || (j<=(1+(i-(11/2)))) || (j>=(7-(i-(11/2))))) System.out.print(" "); else{ System.out.print(j); } } System.out.println(""); } } }
Output:
4 3 4 5 2 3 4 5 6 1 2 3 4 5 6 7 2 3 4 5 6 3 4 5 4
No comments:
Post a Comment