蓝桥网试题 java 基础练习 字母图形

时间:2022-10-21 04:10:26

蓝桥网试题 java 基础练习 字母图形

蓝桥网试题 java 基础练习 字母图形

-----------------------------------------------------------------

不知道说啥

感觉好像偏离主体思想了

但是这样写好简单

-----------------------------------------------------------------

算法

 import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int m = sc.nextInt();
char[] ch = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N',
'O','P','Q','R','S','T','U','V','W','X','Y','Z'};
String st = "";
for(int i=0;i<m;i++)
st += ch[i];
for(int i=0;i<n;i++){
String st1,st2;
if(i!=0){
st1 = st.substring(0, st.length()-1);
st2 = ch[i]+"";
st = st2+st1;
}
System.out.println(st);
}
}
}