C++ 打印镜像直角三角形字母图案程序

使用 for 循环编写一个 C++ 程序来打印镜像直角三角形字母图案。

#include<iostream>
using namespace std;

int main()
{
	int rows;

	cout << "Enter Mirrored Right Triangle of Alphabets Rows = ";
	cin >> rows;

	cout << "The Mirrored Right Triangle Alphabets Pattern\n";

	int alphabet = 65;

	for (int i = 0; i <= rows; i++)
	{
		for (int j = 1; j <= rows - i; j++)
		{
			cout << " ";
		}
		for (int k = 0; k <= i; k++)
		{
			cout << char(alphabet + i);
		}
		cout << "\n";
	}
}
C++ Program to Print Mirrored Right Triangle Alphabets Pattern

使用 while 循环打印镜像直角三角形字母图案的 C++ 程序。

#include<iostream>
using namespace std;

int main()
{
	int rows, i, j, k, alphabet;

	cout << "Enter Mirrored Right Triangle of Alphabets Rows = ";
	cin >> rows;

	cout << "The Mirrored Right Triangle Alphabets Pattern\n";

	alphabet = 65;
	i = 0;

	while (i <= rows)
	{
		j = 1;
		while (j <= rows - i)
		{
			cout << " ";
			j++;
		}

		k = 0;
		while (k <= i)
		{
			cout << char(alphabet + i);
			k++;
		}
		cout << "\n";
		i++;
	}
}
Enter Mirrored Right Triangle of Alphabets Rows = 14
The Mirrored Right Triangle Alphabets Pattern
              A
             BB
            CCC
           DDDD
          EEEEE
         FFFFFF
        GGGGGGG
       HHHHHHHH
      IIIIIIIII
     JJJJJJJJJJ
    KKKKKKKKKKK
   LLLLLLLLLLLL
  MMMMMMMMMMMMM
 NNNNNNNNNNNNNN
OOOOOOOOOOOOOOO

这个 C++ 示例 使用 do while 循环显示镜像直角三角形字母图案。

#include<iostream>
using namespace std;

int main()
{
	int rows, i, j, k, alphabet;

	cout << "Enter Mirrored Right Triangle of Alphabets Rows = ";
	cin >> rows;

	cout << "The Mirrored Right Triangle Alphabets Pattern\n";

	alphabet = 65;
	i = 0;

	do
	{
		j = 1;
		do
		{
			cout << " ";

		} while (j++ <= rows - i);

		k = 0;
		do
		{
			cout << char(alphabet + i);

		} while (++k <= i);
		cout << "\n";

	} while (++i < rows);
}
Enter Mirrored Right Triangle of Alphabets Rows = 17
The Mirrored Right Triangle Alphabets Pattern
                  A
                 BB
                CCC
               DDDD
              EEEEE
             FFFFFF
            GGGGGGG
           HHHHHHHH
          IIIIIIIII
         JJJJJJJJJJ
        KKKKKKKKKKK
       LLLLLLLLLLLL
      MMMMMMMMMMMMM
     NNNNNNNNNNNNNN
    OOOOOOOOOOOOOOO
   PPPPPPPPPPPPPPPP
  QQQQQQQQQQQQQQQQQ