题解 | 牛牛的字符菱形

#include<iostream>
using namespace std;
int main()
{
    int b=0;
    char a;
    cin>>a;
    for(int i=1;i<=5;i++)
    {
        int j=i*2-1;
        int t=i;
        if(j>5)
        {
            t%=3;
             for(;t>0;t--)
            {
                cout<<" ";
            }
            j%=4;
            for(;j>0;j--)
            {
                cout<<a;
            }
            cout<<"\n";
        }
        else {
             for(;t<3;t++)
            {
                cout<<" ";
            }
            for(;j>0;j--)
            {
                cout<<a;
            }
            cout<<"\n";
        }
    }
    system("pause");
    return 0;
}

奇怪,这道题为什么要用这么复杂的解法

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

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