Code: Interesting Alphabets

 Code: Interesting Alphabets

Send Feedback
Pattern for N = 5
E
DE
CDE
BCDE
ABCDE
Input format :
N (Total no. of rows)
Output format :
Pattern in N lines
Constraints
0 <= N <= 26
Sample Input 1:
8
Sample Output 1:
H
GH
FGH
EFGH
DEFGH
CDEFGH
BCDEFGH
ABCDEFGH
Sample Input 2:
7
Sample Output 2:
G
FG
EFG
DEFG
CDEFG
BCDEFG
ABCDEFG


#include<iostream>
using namespace std;


int main() {
int n;
cin>>n;
int row=1;

while(n>=row){
int col=1;
char startchar='A'+n-row;
while(row>=col){
char ch=startchar+col-1;
cout<<ch;
col++;
}
cout<<endl;
row++;
}

/* Read input as specified in the question.
* Print output as specified in the question.
*/
}

Comments

Popular posts from this blog

Code : All connected components

Coding Ninjas