题解 | #上下金字塔#

上下金字塔

https://ac.nowcoder.com/acm/problem/22204

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

        }
        for(int a = 1;a<n;a++){
            for(int b = 0;b<a;b++){
                cout<<' ';
                
            }
            for(int c = 1;c<2*(n-a);c++){
                cout<<"*";
            }
            cout<<endl;
        }
        
        
        
    }
   
    return 0;
}
全部评论

相关推荐

一表renzha:你点进去没打招呼他也会有提示的,之前我点进美的,还没打招呼,他马上给我发了不太合适哦
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务