
4个回答
展开全部
我给写个比较简单的
public class Test2 {
public static void main(String[] args) {
int count = 1;
char abc = 'H';
for(int i = 1;i<=17;i+=2){
for(int k = 17; k>=i;k-=2){
System.out.print(" ");
}
for(int j =1;j<=i;j++){
System.out.print(count);
}
count++;
System.out.println();
}
for(int i = 15;i>=1;i-=2){
for(int k = 0;k<=17-i;k+=2){
System.out.print(" ");
}
for(int j = 1;j<=i;j++){
System.out.print(abc);
}
abc--;
System.out.println();
}
}
}
北京普科国际培训
public class Test2 {
public static void main(String[] args) {
int count = 1;
char abc = 'H';
for(int i = 1;i<=17;i+=2){
for(int k = 17; k>=i;k-=2){
System.out.print(" ");
}
for(int j =1;j<=i;j++){
System.out.print(count);
}
count++;
System.out.println();
}
for(int i = 15;i>=1;i-=2){
for(int k = 0;k<=17-i;k+=2){
System.out.print(" ");
}
for(int j = 1;j<=i;j++){
System.out.print(abc);
}
abc--;
System.out.println();
}
}
}
北京普科国际培训
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
public static void main(String[] args) {
String[] strs = { "1", "2", "3", "4", "5", "6", "7", "8", "9",
"H", "G", "F", "E", "D", "C", "B", "A"};
int length = strs.length;
int halfLength = length / 2;
int spaceLength = 0;
int showLength = 0;
for (int index = 0; index < length; index++) {
spaceLength = index > halfLength ? index - halfLength : halfLength - index;
for (int index2 = 1; index2 <= spaceLength; index2++) {
System.out.print(" ");
}
showLength = 2 * (halfLength - spaceLength) + 1;
for (int index3 = 1; index3 <= showLength; index3++) {
System.out.print(strs[index]);
}
System.out.println();
}
}
String[] strs = { "1", "2", "3", "4", "5", "6", "7", "8", "9",
"H", "G", "F", "E", "D", "C", "B", "A"};
int length = strs.length;
int halfLength = length / 2;
int spaceLength = 0;
int showLength = 0;
for (int index = 0; index < length; index++) {
spaceLength = index > halfLength ? index - halfLength : halfLength - index;
for (int index2 = 1; index2 <= spaceLength; index2++) {
System.out.print(" ");
}
showLength = 2 * (halfLength - spaceLength) + 1;
for (int index3 = 1; index3 <= showLength; index3++) {
System.out.print(strs[index]);
}
System.out.println();
}
}
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询