Interesting Alphabets Pattern
- Get link
- X
- Other Apps
Pattern for N = 5
E
DE
CDE
BCDE
ABCDE
import java.util.Scanner;
public class Solution {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
for(int i=n; i>=1;i--)
{
char c = (char)('A' + i - 1);
for(int j=i ;j<=n;j++)
{
System.out.print(c);
c = (char)(c + 1);
}
System.out.println();
}
}
}
- Get link
- X
- Other Apps
Comments
Post a Comment