当前位置:网站首页>Hollow letter pyramid
Hollow letter pyramid
2022-04-22 08:35:00 【True question OK】
R7-14 Hollow letter pyramid (10 branch )
Enter a capital letter , Output a hollow letter pyramid .
Input format :
One capital letter .
Output format :
A hollow pyramid of capital English letters , Among them the first 1 Layer of “A” In the 1 OK, No 40 Column , List from 1 Start counting .
sample input :
E
sample output :
A
B B
C C
D D
EEEEEEEEE
package java_ test ;
import java.util.*;
public class Main {
public static void main (String[] args) {
Scanner cin = new Scanner(System.in);
char c = cin.next().charAt(0);
// System.out.println(c);
int x = c -'A' + 1;
// System.out.println(x);
// A
// B B
// C C
// D D
// EEEEEEEEE
int cnt = 40;
char ch = 'A';
int num = 0;
// System.out.println(ch);
int m = x;
x = x * 2 + 1;
for (int i = x / 2 + 1; i >=3 ; i--) {
for (int j = 1; j < cnt; j ++) System.out.print(" ");
for (int j = 1; j <= x; j ++) {
if (i == j || j == x + 1 -i)
System.out.print(ch);
else if(j > i && j <= x + 1 - i){
System.out.print(" ");
}
}
ch++;
cnt--;
System.out.println();
}
cnt-=2;
for (int i = 0; i <= cnt; i++) System.out.print(" ");
for (int i = 0; i <= 2 * m - 2; i++) System.out.print(ch);
}
}
版权声明
本文为[True question OK]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220743122741.html
边栏推荐
- 用OnLayoutChangeListener的方法解决getTop=0的问题
- Experiment 2: mathematical basis in Data Science
- Network development in WinForm
- 天翼云等服务器配置Apache Web服务
- Viewpager comprehensive summary
- 技术选型分类(2022)
- The starting point of the final end of the 15th day of the sprint to the big factory
- The PS - EF query process PID in the shell script always returns an exception
- Mapbox设置官方地图语言为中文
- 大一的建议
猜你喜欢

天翼云等服务器配置Apache Web服务

spark sql 获取数组某index处元素

机器学习笔记 - 主成分分析中的数学

The fluent modul class and JSON are converted to each other

100. 相同的树(Easy)

Cesium加载地形数据(cesiumlab制作地形数据),从源数据到地形服务

ARM裸机篇(四)——异常和中断

社会工程学之黑客七宗罪——贪婪(死亡之PING)

The industrialization of SCRM has accelerated, and the manufacturing industry has begun to play with private traffic

postgres+postgis+geoserver离线路径规划功能(记录)
随机推荐
111. 二叉树的最小深度
CPU的基本工作流程
社会工程学之黑客七宗罪——贪婪(死亡之PING)
OLED显示驱动
Redis non relational database - redis high availability, persistence and performance management
构造函数与toString
100. 相同的树(Easy)
oracle 数据库常识以及使用
手把手教你实现RecyclerView的下拉刷新和上拉加载更多
机器学习笔记 - 主成分分析中的数学
第2关:ACL访问控制列表
客户端与服务器通信项目1
数据编码的MFC demo
客户端与服务器项目3
Cloud computing learning 2 - keystone component operation and maintenance and testing
二进制的前导的零
第3关:节点配额及其他命令
指针和数组(操作详解)
Flutter Foundation
Experiment 4: Data Preprocessing