用java怎样打印出如下图形

A BAB CBABC DCBABCD EDCBABCDE行数由用户输入
2024-11-15 21:40:10
推荐回答(3个)
回答1:

char ccc= 97;//这里的97是字母的java的askII编码形式,a的编码是95,A是65;
//num 用与接受用户输入的,具体怎么样接受,根据具体情况;
for(i=0;i int index = i*2+1;
int p=index/2+1;
int q=0;
for(int k=0;k if(p=ccc){
q=1;
}
if(q==0){
p--;
print(ccc);
}
if(q==1){
p++;
print(ccc);
}
}
}

回答2:

对不起,先没有读懂题意...

import java.util.Scanner;
class Graph{
public static void main(String[] args){
Scanner s=new Scanner(System.in);
System.out.print("请输入要显示的行数:");
int m=s.nextInt();
StringBuilder sb=new StringBuilder(),sb2=new StringBuilder();

for(int j=0;j for(char i='A';i sb.append(i);
}

sb2=new StringBuilder(sb);

sb.deleteCharAt(0);
sb.reverse();
sb.append(sb2);
System.out.println(sb);
sb=new StringBuilder();

}
}
}

回答3:

import java.util.Scanner;
class Graph{
public static void main(String[] args){
Scanner s=new Scanner(System.in);
int m=s.nextInt();
StringBuilder sb=new StringBuilder();

for(char i='A';i sb.append(i);
}

StringBuilder sb2=new StringBuilder(sb);

sb.deleteCharAt(0);
sb.reverse();
sb.append(sb2);

System.out.println(sb);

}
}