C++ 打印重复字符的直角三角形程序

编写一个C++程序,使用for循环打印每个直角三角形行中重复的字母或字符。

#include<iostream>
using namespace std;

int main()
{
	int i, j, alphabet, rows;
     
    cout << "Enter Right Triangle Repeated Alphabets Pattern Rows = ";
    cin >> rows;

    cout << "Right Angled Triangle of Repeated Alphabets Pattern\n"; 

    alphabet = 65;

    for(i = 0; i < rows; i++)
    {
    	for(j = 0; j <= i; j++)
		{
            cout << char(alphabet) << " ";
        }
        alphabet++;
        cout << "\n";
    }		
 	return 0;
}
C++ Program to Print Right Triangle of Repeated Characters

这个C++示例使用while循环显示每行重复字符的直角三角形模式。

#include<iostream>
using namespace std;

int main()
{
	int i = 0, j, alphabet, rows;
     
    cout << "Enter Right Triangle Repeated Alphabets Pattern Rows = ";
    cin >> rows;

    cout << "Right Angled Triangle of Repeated Alphabets Pattern\n"; 

    alphabet = 65;

    while(i < rows)
    {
        j = 0;
    	while( j <= i)
		{
            cout << char(alphabet) << " ";
            j++;
        }
        alphabet++;
        cout << "\n";
        i++;
    }		
 	return 0;
}
Enter Right Triangle Repeated Alphabets Pattern Rows = 15
Right Angled Triangle of Repeated Alphabets Pattern
A 
B B 
C C C 
D D D D 
E E E E E 
F F F F F F 
G G G G G G G 
H H H H H H H H 
I I I I I I I I I 
J J J J J J J J J J 
K K K K K K K K K K K 
L L L L L L L L L L L L 
M M M M M M M M M M M M M 
N N N N N N N N N N N N N N 
O O O O O O O O O O O O O O O