Description
Input
一个正整数 n (n<30) 表示要求打印图形的层数。
Output
对应图形
Sample Input
1
Sample Output
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
scanf("%d", &n);
for(int i = 1; i <= (n+1)*2; i++){
if(i==1){
printf("..");
for(int j = 1; j <= 4*n+1; j++) printf("$") ;
printf("..\n");
}else if(i==2){
printf("..$");
for(int j = 1; j <= 4*n-1; j++) printf(".");
printf("$..\n");
}else if(i==(n+1)*2){
for(int j = 1; j <= n; j++) printf("$.");
printf("..$..");
for(int j = 1; j <= n; j++) printf(".$");
printf("\n");
}else{
if(i%2==1){
for(int j = 1; j <= i/2-1; j++) printf("$.");
printf("$$$.");
for(int j = 1; j <= 4*n+1-4*(i/2); j++) printf("$");
printf(".$$$");
for(int j = 1; j <= i/2-1; j++) printf(".$");
}else{
for(int j = 1; j <= i/2-1; j++) printf("$.");
printf("..$");
for(int j = 1; j <= 4*n-1-4*(i-2)/2; j++) printf(".");
printf("$..");
for(int j = 1; j <= i/2-1; j++) printf(".$");
}
printf("\n");
}
}
for(int i = 1; i <= n; i++) printf("$.");
printf("$$$$$");
for(int i = 1; i <= n; i++) printf(".$");
printf("\n");
for(int i = (n+1)*2; i > 0; i--){
if(i==1){
printf("..");
for(int j = 1; j <= 4*n+1; j++) printf("$") ;
printf("..\n");
}else if(i==2){
printf("..$");
for(int j = 1; j <= 4*n-1; j++) printf(".");
printf("$..\n");
}else if(i==(n+1)*2){
for(int j = 1; j <= n; j++) printf("$.");
printf("..$..");
for(int j = 1; j <= n; j++) printf(".$");
printf("\n");
}else{
if(i%2==1){
for(int j = 1; j <= i/2-1; j++) printf("$.");
printf("$$$.");
for(int j = 1; j <= 4*n+1-4*(i/2); j++) printf("$");
printf(".$$$");
for(int j = 1; j <= i/2-1; j++) printf(".$");
}else{
for(int j = 1; j <= i/2-1; j++) printf("$.");
printf("..$");
for(int j = 1; j <= 4*n-1-4*(i-2)/2; j++) printf(".");
printf("$..");
for(int j = 1; j <= i/2-1; j++) printf(".$");
}
printf("\n");
}
}
return 0;
}