Write a program to Display Invert Triangle.
/*
Example:
Input - 5
Output :
5 5 5 5 5
4 4 4 4
3 3 3
2 2
1
*/
public static void main(String args[]){
Example:
Input - 5
Output :
5 5 5 5 5
4 4 4 4
3 3 3
2 2
1
*/
class InvertTriangle{
public static void main(String args[]){
int num = Integer.parseInt(args[0]);
while(num > 0){
for(int j=1;j<=num;j++){
System.out.print(" "+num+" ");
}
System.out.print("\n");
num--;
}
}
}
output:: c:> javac InvertTriangle.java
c:> java InvertTriangle 5
5 5 5 5 5
4 4 4 43 3 3
2 2
1
0 comments:
Post a Comment