题解 | #K形图案#

知识点:

循环控制:循环输出图形

#include <iostream>
using namespace std;

int main() {
    int n;

    while (cin >> n) {
        for (int i = n + 1; i >= 1; i--) {
            for (int j = i; j >= 1; j--) {
                cout << "* ";
            }

            cout << endl;
        }

        for (int i = 2; i <= n + 1; i++) {
            for (int j = 1; j <= i; j++) {
                cout << "* ";
            }

            cout << endl;
        }

        cout << endl;
    }


    return 0;
}


#算法#
全部评论

相关推荐

评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务