题解 | #翻转金字塔图案#

翻转金字塔图案

https://www.nowcoder.com/practice/c4775776e4464537bfb6a5ba37c596c6

#include <iostream>
using namespace std;

int main() {
    int a;
    while (cin >> a) { // 注意 while 处理多个 case
        for (int i = 0; i < a; i++) {

            for (int j = 0; j < i; j++) {
                cout << " ";
            }
            for (int k = 0; k < a - i; k++) {
                cout << "* ";
            }
            cout << endl;
        }
    }
}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

点赞 收藏 评论
分享
牛客网
牛客企业服务