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

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();
        }
    }
}

 

posted @ 2018-01-14 20:40  Bap  阅读(407)  评论(0编辑  收藏  举报