蓝桥杯- 基础练习: 字母图形

蓝桥杯- 基础练习: 字母图形_第1张图片

蓝桥杯- 基础练习: 字母图形_第2张图片

import java.util.Scanner;

public class W {
/*
A B C D E F G
B A B C D E F
C B A B C D E
D C B A B C D
E D C B A B C
 */
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int i = scanner.nextInt();
        int j = scanner.nextInt();
        char chars[][] = new char[i][j];
        for (int x = 0; x < i; x++) {
            char a = 'A';
            char b = (char)(65+x);
            for (int y = 0; y < j; y++) {
                if (x>y) {
                    System.out.print(b--);
                }
                if (x<=y) {
                    System.out.print(a++);
                }
            }
            System.out.println();
        }
    }
}
package shiti;

import java.util.Scanner;

/*
A B C D E F G
B A B C D E F
C B A B C D E
D C B A B C D
E D C B A B C
 */
public class W1 {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int x = scanner.nextInt();
        int y = scanner.nextInt();
        
        for (int i = 0; i < x; i++) {
            for (int j = 0; j < y; j++) {
                if (i>j) {
                    System.out.print((char)(65+i-j));
                }
                if (i<=j) {
                    System.out.print((char)(65-i+j));
                }
            }
            System.out.println();
        }
    }
}

 

转载于:https://www.cnblogs.com/wzqjy/p/8284272.html

你可能感兴趣的:(java)