解题思路:
注意事项:
参考代码:
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
#include<utility>
#include<map>
using namespace std;
char cnt[150][150];
int main(){
int n;
cin>>n;
int tx=0,ty=0;
memset(cnt,'.',sizeof(cnt));
for(int i=n;i>=0;i--){
for(int j=ty+2;j<=ty+4*i+2;j++){
cnt[tx][j]='$';
}
for(int j=tx;j<=tx+2;j++){
cnt[j][ty+2]='$';
cnt[j][ty+4*i+2]='$';
}
for(int j=ty+1;j>=ty;j--){
cnt[tx+2][j]='$';
}
for(int j=ty+4*i+3;j<=ty+4*i+4;j++){
cnt[tx+2][j]='$';
}
for(int j=tx+3;j<=tx+4*i+2;j++){
cnt[j][ty]='$';
}
for(int j=tx+3;j<=tx+4*i+2;j++){
cnt[j][ty+4*i+4]='$';
}
for(int j=ty+1;j<=ty+2;j++){
cnt[tx+4*i+2][j]='$';
}
for(int j=ty+4*i+2;j<=ty+4*i+4;j++){
cnt[tx+4*i+2][j]='$';
}
for(int j=tx+4*i+3;j<=tx+4*i+4;j++){
cnt[j][ty+2]='$';
}
for(int j=tx+4*i+3;j<=tx+4*i+4;j++){
cnt[j][ty+4*i+2]='$';
}
for(int j=ty+3;j<=ty+4*i+1;j++){
cnt[tx+4*i+4][j]='$';
}
tx=tx+2;
ty=ty+2;
}
for(int i=0;i<4*n+5;i++){
for(int j=0;j<4*n+5;j++){
printf("%c",cnt[i][j]);
}
printf("\n");
}
return 0;
}
0.0分
0 人评分
【出圈】 (C语言代码)用单项循环链表浏览:773 |
C二级辅导-统计字符 (C语言代码)浏览:746 |
C语言训练-阿姆斯特朗数 (C语言代码)浏览:854 |
C语言程序设计教程(第三版)课后习题3.7 (C语言代码)浏览:569 |
A+B for Input-Output Practice (VI) (C++代码)浏览:418 |
上车人数 (C语言代码)浏览:781 |
C语言程序设计教程(第三版)课后习题6.7 (C语言代码)浏览:520 |
printf基础练习2 (有点不明白)浏览:845 |
WU-链表数据求和操作 (C++代码)浏览:1317 |
C语言程序设计教程(第三版)课后习题3.7 (C语言代码)浏览:550 |