当前位置:网站首页>[Jiudu OJ 07] folding basket
[Jiudu OJ 07] folding basket
2022-07-06 05:37:00 【CodeLinghu】
【 Nine degrees OJ 07】 Folding basket
One 、 The question
Two 、 The answer process
Ideas :
First define a two-dimensional array , Then fill in characters from inside to outside , Finally, remove the four corners .
Note:
- The coordinates of the characters in the upper left corner of the middle are :
(n/2+1,n/2+1)
- The coordinates of the upper left corner of the secondary middle are :
(n/2+1-1,n/2+1-1)
#include<stdio.h>
int main(){
int outputbuf[82][82];// Output cache for pre typesetting
char a,b;// Two characters entered
int n;// Stack basket size
bool firstcase=true;// Whether it is the first group of data marks , The initial value is true
while(scanf("%d %c %c",&n,&a,&b)==3){
//scanf() The return value of the function is : Number of data items successfully assigned
if(firstcase==true){
// If the first set of data
firstcase=false;// Mark the first set of data as false
}
else printf("\n");
for(int i=1,j=1;i<=n;i+=2,j++){
// Output each circle from the inside out
int x=n/2+1,y=x;//
x-=j-1;y-=j-1;// Calculate the coordinates of the upper right corner of each circle
char c=j%2==1 ?a:b;// Calculate which character the current circle needs to use
for(int k=1;k<=i;k++){
// On the top of the current circle 、 Next 、 Left 、 Right assignment
outputbuf[x+k-1][y]=c;// Left assignment
outputbuf[x][y+k-1]=c;// Upper assignment
outputbuf[x+i-1][y+k-1]=c;// Right assignment
outputbuf[x+k-1][y+i-1]=c;// Lower assignment
}
}
if(n!=1){
// Set the four corners to empty
outputbuf[1][1]=' ';
outputbuf[n][1]=' ';
outputbuf[1][n]=' ';
outputbuf[n][n]=' ';
}
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
printf("%c",outputbuf[i][j]);
}
printf("\n");
}
}
}
边栏推荐
- 27io stream, byte output stream, OutputStream writes data to file
- Deep learning -yolov5 introduction to actual combat click data set training
- The digital economy has broken through the waves. Is Ltd a Web3.0 website with independent rights and interests?
- How can large websites choose better virtual machine service providers?
- 指针经典笔试题
- [leetcode] 18. Sum of four numbers
- Knowledge points of circular structure
- js Array 列表 实战使用总结
- Excel转换为Lua的配置文件
- Figure database ongdb release v-1.0.3
猜你喜欢
Sword finger offer II 039 Maximum rectangular area of histogram
04. Project blog log
初识CDN
Vulhub vulnerability recurrence 68_ ThinkPHP
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
网站进行服务器迁移前应做好哪些准备?
数字经济破浪而来 ,LTD是权益独立的Web3.0网站?
Self built DNS server, the client opens the web page slowly, the solution
自建DNS服务器,客户端打开网页慢,解决办法
Problems encountered in installing mysql8 on MAC
随机推荐
Codeforces Round #804 (Div. 2) Editorial(A-B)
ArcGIS应用基础4 专题图的制作
UCF (summer team competition II)
什么是独立IP,独立IP主机怎么样?
05. 博客项目之安全
Codeless June event 2022 codeless Explorer conference will be held soon; AI enhanced codeless tool launched
PDK工艺库安装-CSMC
Deep learning -yolov5 introduction to actual combat click data set training
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
【torch】|torch.nn.utils.clip_grad_norm_
Note the various data set acquisition methods of jvxetable
MySQL advanced learning summary 9: create index, delete index, descending index, and hide index
C# AES对字符串进行加密
Game push: image / table /cv/nlp, multi-threaded start!
PDK工藝庫安裝-CSMC
备忘一下jvxetable的各种数据集获取方法
HAC集群修改管理员用户密码
SQLite add index
Redis消息队列
Game push image / table /cv/nlp, multi-threaded start