当前位置:网站首页>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 :
边栏推荐
- UE4 source code reading_ Mobile synchronization
- Development experience and experience
- Really explain the five data structures of redis
- 20220630学习打卡
- Dom4j traverses and updates XML
- JS non Boolean operation - learning notes
- 【Rust 笔记】13-迭代器(上)
- Message queue for interprocess communication
- Find the intersection of line segments
- [concurrent programming] collaboration between threads
猜你喜欢
Allocation exception Servlet
Unity editor expansion - controls, layouts
[concurrent programming] consistency hash
单调栈-42. 接雨水
Really explain the five data structures of redis
Notes and bugs generated during the use of h:i:s and y-m-d
OpenGL learning notes
MySQL three logs
Cloudcompare learning (1) - cloudcompare compilation and common plug-in implementation
22-06-28 Xi'an redis (02) persistence mechanism, entry, transaction control, master-slave replication mechanism
随机推荐
Unity Editor Extension - event handling
Facial expression recognition based on pytorch convolution -- graduation project
MySQL index types B-tree and hash
【Rust笔记】06-包和模块
DOM 渲染系统(render mount patch)响应式系统
UE4 source code reading_ Bone model and animation system_ Animation node
【Rust 笔记】07-结构体
22-06-28 西安 redis(02) 持久化机制、入门使用、事务控制、主从复制机制
Dealing with duplicate data in Excel with xlwings
Intersectionpicker in osgearth
[linear table] basic operation of bidirectional linked list specify node exchange
【Rust 笔记】08-枚举与模式
求组合数 AcWing 886. 求组合数 II
Escape from heaven and forget what he suffered. In ancient times, it was called the punishment of escape from heaven. Article collection
【Rust 笔记】09-特型与泛型
[concurrent programming] working mechanism and type of thread pool
Unity Editor Extension - Outline
【Rust 笔记】10-操作符重载
Parameters of convolutional neural network
Simple demo of solving BP neural network by gradient descent method