java循环输出ABCD等腰三腰形
来源:百度知道 编辑:UC知道 时间:2024/05/21 20:00:03
class Guess {
//
参数1: 你需要的行数 参数2:首字母
static public void printX(int row,char beginChar)
{
for(int i=1;i<=row;i++)
{
for(int j=1;j<row*2;j++)
{
if(j>row+i-1 || j<row-i+1) System.out.print(" ");
else {
if(j<row) System.out.print((char)((int)beginChar+i-1-(row-j)));
else if(j>row) System.out.print((char)((int)beginChar+i-1+(row-j)));
else System.out.print((char)((int)beginChar+i-1));
}
}
System.out.println();
}
}
static public void main(String[] sss){
printX(11,'A');
}
}
一个static函数
//修改n的值,可以是1到26或更大也可以:
public class Print {
static int n = 26;
static char c = 'A';
static char[][] arr = new char[n][];
static int num = 1;
public static void main(String[] args) {