蓝桥杯·字母图形·Java实现

import java.util.Scanner;

public class Main  {

    public  static  void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int row = sc.nextInt();
        int col = sc.nextInt();
        for (int i = 0 ;i<row;i++){
            int j = 0;
            for (char a = (char) ('A' + i); a>'A'&& j<col; a--){ 
                System.out.print(a);
                j++;
            }
            for (char a = (char)('A');a<='Z'&& j<col;a++){
                System.out.print(a);
                j++;
            }
            System.out.print("\n");

        }

    }
}

猜你喜欢

转载自xiqingongzi.iteye.com/blog/2344188