C++中巧妙输出n图形

#include<iostream>
using namespace std;

int main(){
    //输出n图形
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            if(j==1||j==i||j==n){
                cout<<"*";
            }else{
                cout<<" ";
            }
            
        }
        cout<<endl;
    }
    
    return 0;
}

猜你喜欢

转载自blog.csdn.net/qq_37651894/article/details/96643634
今日推荐