当前位置:网站首页>PAT1027 Printing Hourglass
PAT1027 Printing Hourglass
2022-08-09 16:18:00 【Yellow duck 233】
#include <stdio.h>
#include <string.h>
int shalou(size_t size, char s)
{
int top = 0;
if(size == 0)
return 0;
for(int i = 3; i <= 10000; i += 2)
{
top += i;
if(top*2+1 > size)
{
top -= i;
size = top == 1 ? 1 : top * 2 + 1;
break;
}
}
char arr[1000][1000];
int cnt = 0, index = 0;
for(int i = 1; cnt < top + 1; i+=2)
{
cnt+=i;
for(int j = 0; j < i; j++)
arr[index][j] = s;
index++;
}
for(int i = index - 1; i >= 0; i --)
{
for(int j = 0; j < (strlen(arr[index - 1])-strlen(arr[i]))/2; j++)
printf(" ");
printf("%s\n", arr[i]);
}
for(int i = 1; i < index; i++)
{
for(int j = 0; j < (strlen(arr[index - 1])-strlen(arr[i]))/2; j++)
printf(" ");
printf("%s\n", arr[i]);
}
return size;
}
int main()
{
int n;
char c;
scanf("%d %c", &n, &c);
int la = n - shalou(n, c);
printf("%d\n", la);
return 0;
}
边栏推荐
- pytorch从零搭建神经网络实现多分类(训练自己的数据集)
- EasyExcel的应用
- What is a template engine?What are the common template engines?Introduction to common commands of thymeleaf.
- 名词概念总结(不定期更新~~)
- 如何保证电脑硬盘格式化后数据不能被恢复?
- 常见编译问题
- WebGL:BabylonJS入门——初探:数据展示
- 如何通过通达信量化交易接口达到长期的收益?
- 通用的双向循环列表的几个比较重要的函数操作
- Talking about Shallow Cloning and Deep Cloning of ArraryList
猜你喜欢
随机推荐
双摄像头系列原理深度剖析【转载】
量化程序化交易如何去使用以及执行?
跨平台桌面应用 Electron 尝试(VS2019)
xshell7连接工具下载
How do quantitative investors obtain real-time market data?
How to List < Map> grouping numerical merge sort
Matlab修改Consolas字体
redis从入门到精通
Common compilation problems
.Net Core动态注入
WebGL:BabylonJS入门——初探:我的世界
CV复习:过拟合、欠拟合
Grad CAM model visualization
EasyExcel的应用
在服务器上远程使用tensorboard
正则化原理的简单分析(L1/L2正则化)
6大论坛,30+技术干货议题,2022首届阿里巴巴开源开放周来了!
OpenCV简介与搭建使用环境
SNR 信噪比
九、【Vue-Router】缓存路由组件 keep-alive标签