1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
| /* 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
*/
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--;
}
}
} |
/* 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
*/
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--;
}
}
}
ABCDEFG
ABCDEF
ABCDE
ABCD
ABC
AB
A
HOW TO SOLVE THIS PETTERN IN JAVA
ABCDEF
ABCDE
ABCD
ABC
AB
A
HOW TO SOLVE PATTERN IN JAVA
ABCDEFG
ABCDEF
ABCDE
ABCD
ABC
AB
A
HOW TO SOLVE THIS PETTERN IN JAVA – See more at: http://studentprojects.in/source-codes/software-programs/java/basic-programs/java-program-generate-invert-triangle-4444-333-22-1/#sthash.qEb8yLEZ.dpuf
54321
4321
321
21
1
how top solve this problem in java
public static void main(String args[]){
int num = 10; //taking no. as command line
String alphabates=”ABCDEFGHIJKLMNOPQRSTUVWXYZ”;
while(num > 0 && num<27){
for(int j=0;j<num;j++){
System.out.print(alphabates.charAt(j)+" ");
}
System.out.print("\n");
num–;
}
}
public static void main(String args[]){
int num = 4;
String alphabates=”ABCDEFGHIJKLMNOPQRSTUVWXYZ”;
if(num>0 && num<27){
for(int a=0;a<num;a++){
for(int b=0;b 0 && num<27){
for(int j=0;j<num;j++){
System.out.print(alphabates.charAt(j)+" ");
}
System.out.print("\n");
num–;
}
}
/* OUTPUT :
A
A B
A B C
A B C D
A B C
A B
A
*/
A
BB
CCC
DDDD
EEEEE