import java.util.Scanner;
public class GetLetterArray
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
System.out.println("请输入所要输出矩阵的行数和列数: ");
char[][] arr = new char[sc.nextInt()][sc.nextInt()];
int d = 0;
for (int i = 0;i < arr.length ; i++)
{
for (int j = 0;j < arr[0].length;j++ )
{
arr[i][j] = (char)(65 + d);
d++;
}
}
for (char[] ch : arr) //foreach遍历数组
{
for (char cha : ch )
{
System.out.print(cha + " ");
}
System.out.println();
}
}
}
java编写字母顺序矩阵
最新推荐文章于 2022-03-16 19:47:20 发布