3 条题解

  • 0
    @ 2023-12-26 2:27:08

    switch分行输出,暴力解

    import java.util.Scanner;
    
    public class Main {
        public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            int[] arr = new int[4];
            while(sc.hasNextInt()){
                arr[0] = sc.nextInt();
                arr[1] = sc.nextInt();
                arr[2] = sc.nextInt();
                arr[3] = sc.nextInt();
    
                for(int i = 0;i < 4;i++){
                    if(arr[i] == 1 || arr[i] == 4){
                        System.out.print("   ");
                    }else{
                        System.out.print(" _ ");
                    }
                }
                System.out.println();
    
                for(int i = 0;i < 4;i++){
                    switch (arr[i]){
                        case 1:
                        case 7:
                            System.out.print("  |");
                            break;
                        case 2:
                        case 3:
                            System.out.print(" _|");
                            break;
                        case 4:
                        case 8:
                        case 9:
                            System.out.print("|_|");
                            break;
                        case 5:
                        case 6:
                            System.out.print("|_ ");
                            break;
                        case 0:
                            System.out.print("| |");
                            break;
    
                    }
                }
                System.out.println();
    
                for(int i = 0;i < 4;i++){
                    switch (arr[i]){
                        case 1:
                        case 4:
                        case 7:
                            System.out.print("  |");
                            break;
                        case 2:
                            System.out.print("|_ ");
                            break;
                        case 3:
                        case 5:
                        case 9:
                            System.out.print(" _|");
                            break;
                        case 6:
                        case 8:
                        case 0:
                            System.out.print("|_|");
                            break;
    
                    }
                }
                System.out.println();
            }
    
        }
    }
    
    
    

    信息

    ID
    3
    时间
    1000ms
    内存
    32MiB
    难度
    9
    标签
    (无)
    递交数
    27
    已通过
    4
    上传者