3 solutions

  • 0
    @ 2022-4-10 17:24:17
    
    
    import java.util.Scanner;
    
    public class Main {
    
        public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            int end = sc.nextInt() + sc.nextInt();
            int n1, n2;
            n1 = end / 10;
            n2 = end % 10;
            String[][] stars = stars(n1, n2);
            printString(stars);
        }
    
        static String[][] copyT(String[][] a, String[][] b) {
            String[][] c = new String[5][7];
            for (int i = 0; i < 5; i++) {
                for (int j = 0; j < 3; j++) {
                    c[i][j] = a[i][j];
                }
            }
            for (int i = 0; i < 5; i++) {
                c[i][3] = " ";
            }
            for (int i = 0; i < 5; i++) {
                for (int j = 4; j < 7; j++) {
                    c[i][j] = b[i][j - 4];
                }
            }
            return c;
        }
    
        static String[][] stars(int n1, int n2) {
            String[][] a = drawStars(n1);
            String[][] b = drawStars(n2);
            return copyT(a, b);
        }
    
        static String[][] drawStars(int n) {
            String[][] a = new String[5][3];
            reset(a);
            if (n == 0) {
                s0(a);
            } else if (n == 1) {
                s1(a);
            } else if (n == 2) {
                s2(a);
            } else if (n == 3) {
                s3(a);
            } else if (n == 4) {
                s4(a);
            } else if (n == 5) {
                s5(a);
            } else if (n == 6) {
                s6(a);
            } else if (n == 7) {
                s7(a);
            } else if (n == 8) {
                s8(a);
            } else if (n == 9) {
                s9(a);
            }
            return a;
        }
    
        static void reset(String[][] a) {
            for (int i = 0; i < 5; i++) {
                for (int j = 0; j < 3; j++) {
                    a[i][j] = "*";
                }
            }
        }
    
        static void s9(String[][] a) {
            s8(a);
            a[3][0] = " ";
        }
    
        static void s8(String[][] a) {
            s0(a);
            a[2][1] = "*";
        }
    
        static void s7(String[][] a) {
            for (int i = 1; i < 5; i++) {
                a[i][0] = " ";
                a[i][1] = " ";
            }
        }
    
        static void s6(String[][] a) {
            s5(a);
            a[3][0] = "*";
        }
    
        static void s5(String[][] a) {
            s3(a);
            a[1][0] = "*";
            a[1][2] = " ";
        }
    
        static void s4(String[][] a) {
            s9(a);
            a[0][1] = " ";
            a[4][1] = " ";
            a[4][0] = " ";
        }
    
        static void s3(String[][] a) {
            s2(a);
            a[3][2] = "*";
            a[3][0] = " ";
        }
    
        static void s2(String[][] a) {
            s0(a);
            a[2][1] = "*";
            a[1][0] = " ";
            a[3][2] = " ";
        }
    
        static void s1(String[][] a) {
            for (int i = 0; i < 5; i++) {
                a[i][0] = " ";
                a[i][2] = " ";
            }
        }
    
        static void s0(String[][] a) {
            a[1][1] = " ";
            a[2][1] = " ";
            a[3][1] = " ";
        }
    
        static void printString(String[][] a) {
            for (int i = 0; i < 5; i++) {
                for (int j = 0; j < 7; j++) {
                    System.out.print(a[i][j]);
                }
                if (i != 4) {
                    System.out.println();
                }
            }
        }
    }
    

    Information

    ID
    29
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    3
    Tags
    # Submissions
    176
    Accepted
    89
    Uploaded By