当前位置:网站首页>Complex character + number pyramid
Complex character + number pyramid
2022-07-03 08:50:00 【Cap07】
#include<iostream>
#include<string>
using namespace std;
int main() { //1 3 5 7 2n-1
char c;
cin >> c; // Input range : character :A-Z Numbers :1-9
if (c >= 'A' && c <= 'Z') {
int num = c - 'A' + 1; // Row number
for (int i = 1; i <= num; i++) { // Loop out each line
for (int j = 1; j <= num - i; j++) { // Front space
cout << " ";
}
for (char x = 'A'; x <= 'A' + i - 1; x++) { // Add the first half of the characters
cout << x;
}
for (char x = 'A' + i - 2; x >= 'A'; x--) { // Second half character
cout << x;
}
for (int j = 1; j <= num - i; j++) { // Space after
cout << " ";
}
cout << "" << endl;
}
}
else {
int num = c - 48;
for (int i = 1; i <= num; i++) { // Loop out each line
for (int j = 1; j <= num - i; j++) {
cout << " ";
}
for (int x = 1; x <= i; x++) {
cout << x;
}
for (int x = i - 1; x >= 1; x--) {
cout << x;
}
for (int j = 1; j <= num - i; j++) {
cout << " ";
}
cout << "" << endl;
}
}
return 0;
}
//00100
//01210
//12321
test result :
边栏推荐
- Deep parsing (picture and text) JVM garbage collector (II)
- 单调栈-503. 下一个更大元素 II
- 基于SSM的校园失物招领平台,源码,数据库脚本,项目导入运行视频教程,论文撰写教程
- Unity editor expansion - controls, layouts
- Binary to decimal, decimal to binary
- 22-06-27 Xian redis (01) commands for installing five common data types: redis and redis
- [rust notes] 09- special types and generics
- Unity editor expansion - draw lines
- Concurrent programming (III) detailed explanation of synchronized keyword
- 【Rust笔记】02-所有权
猜你喜欢
[concurrent programming] consistency hash
Log4j2 vulnerability recurrence and analysis
Unity editor expansion - draw lines
求组合数 AcWing 886. 求组合数 II
Unity learning notes
MySQL 8
Dom4j traverses and updates XML
Binary tree traversal (first order traversal. Output results according to first order, middle order, and last order)
JS ternary operator - learning notes (with cases)
【Rust笔记】02-所有权
随机推荐
数据库原理期末复习
22-06-28 Xi'an redis (02) persistence mechanism, entry, transaction control, master-slave replication mechanism
【Rust 笔记】09-特型与泛型
TP5 multi condition sorting
[concurrent programming] atomic operation CAS
Redux - learning notes
On the difference and connection between find and select in TP5 framework
JS ternary operator - learning notes (with cases)
Common DOS commands
cres
Graphics_ Learnopongl learning notes
Alibaba canal actual combat
Monotonic stack -503 Next bigger Element II
Notes on understanding applets 2022/7/3
[concurrent programming] consistency hash
Binary tree sorting (C language, int type)
On the setting of global variable position in C language
Osganimation library parsing
使用dlv分析golang进程cpu占用高问题
Convert video to GIF