美文网首页
C++语言程序设计基础作业

C++语言程序设计基础作业

作者: HM955 | 来源:发表于2018-02-21 19:20 被阅读0次

    打印 n 阶实心菱形:

    #include <iostream>
    using namespace std;
    
    int main()
    {
        int n;
        cin >> n;
        
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= n - i; j++)
                cout << " ";
            for (int j = 1; j <= 2 * i - 1; j++)
                cout << "*";
            cout << endl;
        }
        
        for (int i = n - 1; i >= 1; i--) {
            for (int j = 1; j <= n - i; j++)
                cout << " ";
            for (int j = 1; j <= 2 * i - 1; j++)
                cout << "*";
            cout << endl;
        }
        return 0;
    }
    

    2-2的题目不怎么会做我决定先放下,我好弱智啊

    相关文章

      网友评论

          本文标题:C++语言程序设计基础作业

          本文链接:https://www.haomeiwen.com/subject/scpotftx.html