1. 程式人生 > >藍橋杯- 基礎練習: 字母圖形

藍橋杯- 基礎練習: 字母圖形

alt gpo pan 圖片 -- ext .com color ack

技術分享圖片

技術分享圖片

技術分享圖片

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

藍橋杯- 基礎練習: 字母圖形