当前位置:网站首页>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
//12321test result :


边栏推荐
- Find the intersection of line segments
- Parameters of convolutional neural network
- [rust notes] 05 error handling
- 22-06-28 Xi'an redis (02) persistence mechanism, entry, transaction control, master-slave replication mechanism
- Unity Editor Extension - event handling
- 【Rust 笔记】07-结构体
- [rust notes] 11 practical features
- [rust notes] 07 structure
- Solution of 300ms delay of mobile phone
- [rust notes] 08 enumeration and mode
猜你喜欢
![[concurrent programming] concurrent tool class of thread](/img/16/2b4d2b3528b138304a1a3918773ecf.jpg)
[concurrent programming] concurrent tool class of thread

Dealing with duplicate data in Excel with xlwings

UE4 source code reading_ Bone model and animation system_ Animation compression

二进制转十进制,十进制转二进制

Monotonic stack -84 The largest rectangle in the histogram

First Servlet

I made mistakes that junior programmers all over the world would make, and I also made mistakes that I shouldn't have made

Dom4j遍历和更新XML

数据库原理期末复习

请求参数的发送和接收
随机推荐
22-06-27 西安 redis(01) 安装redis、redis5种常见数据类型的命令
Deeply understand the underlying data structure of MySQL index
Visual Studio (VS) shortcut keys
Development material set
VIM learning notes from introduction to silk skating
OpenGL learning notes
[concurrent programming] collaboration between threads
[rust notes] 11 practical features
Servlet的生命周期
Unity learning notes
Constraintlayout's constraintset dynamically modifies constraints
Escape from heaven and forget what he suffered. In ancient times, it was called the punishment of escape from heaven. Article collection
Try to reprint an article about CSDN reprint
How does unity fixedupdate call at a fixed frame rate
【Rust笔记】06-包和模块
注解简化配置与启动时加载
PHP mnemonic code full text 400 words to extract the first letter of each Chinese character
php public private protected
单调栈-42. 接雨水
Mortgage Calculator