如果可以,可以陪你千年不老,千年只想眷顾你倾城一笑;如果愿意,愿意陪你永世不离,永世只愿留恋你青丝白衣。

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <ctime>
#include <cctype>
#include <bitset>
#include <utility>
#include <sstream>
#include <complex>
#include <iomanip>
#define inf 0x3f3f3f3f
typedef long long ll;
using namespace std;
int n;
char G[10010][10010];
int main()
{
    cin>>n;
    for(int i=0; i<4*(n+1)+1; i++)
    {
        if(i==0)    //第一行
        {
            for(int j=0; j<5+4*n; j++)
            {
                if(j==0 || j==1 || j==5+4*n-1 || j==5+4*n-2)
                    G[i][j]='.';
                else
                    G[i][j]='$';
            }
        }
        else if(i==1)   //第二行
        {
            for(int j=0; j<5+4*n; j++)
            {
                if(j==2 || j==5+4*n-1-2)
                    G[i][j]='$';
                else
                    G[i][j]='.';
            }
        }
        else if(i<=2*n+2)
        {
            //第三行开始,每一行是上一行的反转(‘$变. , .变$’),新的位补$,
            for(int j=2*n+3-1; j>=1; j--)
            {
                if(G[i-1][j-1]=='.')
                    G[i][j]='$';
                else
                    G[i][j]='.';
            }
            G[i][0]='$';
            for(int j=2*n+3; j<5+4*n; j++)
                G[i][j]=G[i][5+4*n-j-1];
        }
        else
        {
            //后半2*n+2行是前面行的对称
            for(int j=0; j<5+4*n; j++)
                G[i][j]=G[5+4*n-i-1][j];
        }
    }
    for(int i=0; i<4*n+5; i++)
    {
        for(int j=0; j<4*n+5; j++)
            cout<<G[i][j];
        cout<<endl;
    }
    return 0;
}

 

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐