【问题标题】:Need help making letters with asterisks需要帮助制作带星号的字母
【发布时间】: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;
                }
            }
        }

    }

【问题讨论】:

    标签: c++ letters


    【解决方案1】:

    我们不是来帮你解决家庭作业的。你的问题太开放了,除了“idk how to do this please do it for me”之外没有任何实际问题。如果我不得不推荐一些步骤,我会说使用星号绘制 txt 文件中的每个字母。然后弄清楚你需要循环哪些部分,哪些部分需要打印出来。

    例如 T。 我会通过首先在 T 的顶部打印一行星号来解决它。然后制作一个循环,打印出一个带有空白的星号,每次你觉得应该制作 T 的底部.

    【讨论】:

    • 我不是要求你们解决它,只是为了提供一些指导。第二段真的帮助了我。非常感谢你。
    • L 也很简单,一个带有 x 数量空格的星号,后跟一行星号在底部。 O在你身上
    • 如果你能写一个代码示例也很棒。非常感谢。
    猜你喜欢
    • 2020-06-10
    • 1970-01-01
    • 1970-01-01
    • 2012-08-11
    • 1970-01-01
    • 2019-09-03
    • 1970-01-01
    • 2019-11-02
    • 1970-01-01
    相关资源
    最近更新 更多