当前位置:网站首页>[PTA] l1-002 printing hourglass
[PTA] l1-002 printing hourglass
2022-04-23 20:23:00 【Maybe】
Prepare knowledge points
A sequence of equal differences
General term sum formula

Original link
Their thinking
Calculate the number of rows by using the sequence of equal differences
ac Code
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;
int main() {
int t;
char a;
cin >> t;
getchar();
cin >> a;
int n = (t + 1) / 2;
n = int(sqrt(n));// Number of upper triangular rows
t = t - n * n * 2 + 1;
for(int i = 0; i < n; i++){
for(int j = 0; j < i; j++)
cout << ' ';
for(int j = 0; j < 2 * (n - i) - 1; j++)
cout << a;
cout << endl;
}
for(int i = n - 2; i >= 0; i--){
for(int j = i; j > 0; j--)
cout << ' ';
for(int j = 0; j < 2 * (n - i) - 1; j++)
cout << a;
cout << endl;
}
cout << t;
return 0;
}
版权声明
本文为[Maybe]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204232020000365.html
边栏推荐
- 网络通信基础(局域网、广域网、IP地址、端口号、协议、封装、分用)
- Browser - learning notes
- Investigate why close is required after sqlsession is used in mybatties
- R语言使用econocharts包创建微观经济或宏观经济图、indifference函数可视化无差异曲线、自定义计算交叉点、自定义配置indifference函数的参数丰富可视化效果
- BMP JPEG 图片转换为矢量图像 ContourTrace
- 考研英语唐叔的语法课笔记
- selenium. common. exceptions. WebDriverException: Message: ‘chromedriver‘ executable needs to be in PAT
- Don't bother tensorflow learning notes (10-12) -- Constructing a simple neural network and its visualization
- selenium.common.exceptions.WebDriverException: Message: ‘chromedriver‘ executable needs to be in PAT
- Redis cache penetration, cache breakdown, cache avalanche
猜你喜欢

考研英语唐叔的语法课笔记

Automatically fill in body temperature and win10 task plan

Click an EL checkbox to select all questions

Three. Based on ply format point cloud voxel model JS upload interface writing

Servlet learning notes
![Es error: request contains unrecognized parameter [ignore_throttled]](/img/17/9131c3eb023b94b3e06b0e1a56a461.png)
Es error: request contains unrecognized parameter [ignore_throttled]

Commit and ROLLBACK in DCL of 16mysql

DNS cloud school | quickly locate DNS resolution exceptions and keep these four DNS status codes in mind

Mysql database backup scheme

On BIM data redundancy theory
随机推荐
Modeling based on catiav6
Some basic knowledge of devexpress report development
JDBC tool class jdbcfiledateutil uploads files and date format conversion, including the latest, simplest and easiest way to upload single files and multiple files
Operation of numpy array
Mathematical modeling column | Part 5: MATLAB optimization model solving method (Part I): Standard Model
SQL Server Connectors By Thread Pool | DTSQLServerTP plugin instructions
SQL Server Connectors By Thread Pool | DTSQLServerTP 插件使用说明
【栈和队列专题】—— 滑动窗口
Computing the intersection of two planes in PCL point cloud processing (51)
【目标跟踪】基于帧差法结合卡尔曼滤波实现行人姿态识别附matlab代码
微信中金财富高端专区安全吗,证券如何开户呢
selenium. common. exceptions. WebDriverException: Message: ‘chromedriver‘ executable needs to be in PAT
R语言ggplot2可视化:ggplot2可视化散点图并使用geom_mark_ellipse函数在数据簇或数据分组的数据点周围添加椭圆进行注释
网络通信基础(局域网、广域网、IP地址、端口号、协议、封装、分用)
Sqoop imports data from Mysql to HDFS using lzop compression format and reports NullPointerException
Numpy sort search count set
Browser - learning notes
三十.什么是vm和vc?
还在用 ListView?使用 AnimatedList 让列表元素动起来
Research on open source OCR engine