【发布时间】:2018-03-23 18:30:08
【问题描述】:
我必须在 c++ 中使用星号来制作字母“T”、“O”和“L”。代码要求提供尺寸和字母。这就是我到目前为止所拥有的。老实说,我根本不擅长循环,我该如何制作循环?一些逐步的解释也将不胜感激。万分感谢。这是我的代码。
#include<iostream>
using namespace std;
int main()
{
char T, O, L;
char letter;
int number, size;
size = number % 2;
cout << "Welcome to the letter printer." << endl;
cout << "Enter the size : " << endl;
cin >> size;
while (size <= 5 || size == 0)
{
cout << "Invalid size. Enter the size again: ";
cin >> size;
}
cout << "Enter the letter: " << endl;
cin >> letter;
while (letter != 'T' && letter != 'O' && letter != 'L')
{
cout << "Invalid Letter. Enter the letter again:";
cin >> letter;
{
while (letter == 'T')
{
for (int i = 0; i < size; i++)
{
for (int j = 0; j < size; j++)
{
cout << "*";
}
cout << endl;
}
}
}
}
【问题讨论】: