Program: 9
Output: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-1))))) System.out.print(" "); else System.out.print("*"); } System.out.println(""); } } }
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Program: 10
public class HelloWorld{ public static void main(String []args){ for(int i=11;i>=0;i--){ for(int j=0;j<10;j++){ if((j<(0+((11/2)-(i)))) || (j>=(11-((11/2)-(i-1))))) System.out.print("*"); else System.out.print(" "); } System.out.println(""); } } }
Output:
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
No comments:
Post a Comment