Java印刷グラフィック

12842 ワード

public class Work12 {

    public static void main(String[] args) {
        /* 
        
          :
        *****
        ****
        ***
        **
        *
          ,        *, for    
            */
        
        for(int j = 1; j <= 5; j++){
            for(int i = 1; i <= 6-j; i++){
                System.out.print("*");
            }
            System.out.println();
        }



/* 
        
          :
        *******
         *****
          ***
           *
          ,        *, for    
            */
        
        //   for      
        for(int j = 1; j <= 4; j++){
            //        
            for(int i = 1; i <= j-1; i++){
                System.out.print(" ");
            }
            //      *
            for(int i = 1; i <= 9-2*j; i++){
                System.out.print("*");
            }
            System.out.println();
        }


/* 
        
          :
        A
        BB
        CCC
        DDDD
        EEEEE
          ,        *, for    
            */
    
        char c = 64;
        
        //   for      
        for(int j = 1; j <= 5; j++){
            for(int i = 1; i <= j; i++){
                System.out.print((char)(c+j));
            }
            System.out.println();
        }



/* 
        
          :
             *
            * *
           *   *
          *******
          ,        *, for    
            */
        
        
        //   for      
        for(int j = 1; j <= 4; j++){
            for(int i = 1; i <= 4-j; i++){
                System.out.print(" ");
            }

            for(int i = 1; i <= 2*j-1; i++){
//              System.out.print("*");
                if(i == 1 || i == 2*j-1 || j == 4){
                    System.out.print("*");
                }else{
                    System.out.print(" ");
                }
            }
            System.out.println();
        }

/* 
        
          :
             *
            * *
           *   *
          *******
          ,        *, for    
            */
        
        
        //   for      
        for(int j = 1; j <= 4; j++){
            for(int i = 1; i <= 4-j; i++){
                System.out.print(" ");
            }

            for(int i = 1; i <= 2*j-1; i++){
//              System.out.print("*");
                if(i == 1 || i == 2*j-1 || j == 4){
                    System.out.print("*");
                }else{
                    System.out.print(" ");
                }
            }
            System.out.println();
        }


/* 
        
          :
             *
            * *
           *   *
          *     *
           *   *
            * *
             *
          ,        *, for    
            */
        
        //    
        for(int j = 1; j <= 4; j++){
            for(int i = 1; i <= 4-j; i++){
                System.out.print(" ");
            }

            for(int i = 1; i <= 2*j-1; i++){
//              System.out.print("*");
                if(i == 1 || i == 2*j-1){
                    System.out.print("*");
                }else{
                    System.out.print(" ");
                }
            }
            System.out.println();
        }
        
        //    
        for(int j = 1; j <= 3; j++){
            //        
            for(int i = 1; i <= j-1+1; i++){
                System.out.print(" ");
            }
            //      *
            for(int i = 1; i <= 9-2*j-2; i++){
                if(i == 1 || i == 9-2*j-2){
                    System.out.print("*");
                }else{
                    System.out.print(" ");
                }
            }
            System.out.println();
        }
        



    }
}







import java.util.Scanner;


public class Work {

    public static void main(String[] args) {
        
        Scanner scan = new Scanner(System.in);
        boolean flag = true;
        //    
        String[][] students = new String[1024][];
        //    
        int count = 0;
        
        
        while(flag){
            
            System.out.println("******************************");
            System.out.println("*                                        *");
            System.out.println("*              :                          *");
            System.out.println("*         1、                          *");
            System.out.println("*         2、                          *");
            System.out.println("*         3、                          *");
            System.out.println("*         4、                          *");
            System.out.println("*         5、                          *");
            System.out.println("******************************");
            System.out.print("       :");
            int code = scan.nextInt();
            switch(code){
            case 1:
                boolean flag1 = true;
                while(flag1){
                    System.out.println("       "+(count+1)+"      :");
                    String stuno;
                    while(true){
                        System.out.print("     :");
                        stuno = scan.next();
                        //                
                        int i = 0;
                        for(; i < count; i++){
                            if(stuno.equals(students[i][0])){
                                System.out.println("      ,     !");
                                break;
                            }
                        }
                        if(i == count){
                            //      ,  while  ,       
                            break;
                        }
                    }
                    System.out.print("     :");
                    String name = scan.next();
                    System.out.print("     :");
                    String age = scan.next();
                    System.out.print("     :");
                    String gender = scan.next();
                    System.out.print("     :");
                    String telno = scan.next();
                    //        
                    students[count] = new String[]{stuno,name,age,gender,telno};
                    //  +1
                    count++;
                    System.out.print("          ,  M/m    ,  F/f    ,        :");
                    String s = scan.next();
                    if(s.equals("m") || s.equals("M")){
                        //    
                        flag = true;
                        flag1 = false;
                    }else if(s.equals("f") || s.equals("F")){
                        //    ,      
                        System.out.println("    ,ヾ( ̄▽ ̄)Bye~Bye~");
                        System.exit(0);
                    }
                }
                break;
            case 2:
                //      students     ,    ,    
                System.out.println("  "+count+"   ,      :");
                System.out.println("  ------  ------  ------  ------  ------");
                for(int i = 0; i < count; i++){
                    for(int j = 0; j < students[i].length; j++){
                        System.out.print(students[i][j]+"\t");
                    }
                    System.out.println();
                }
                System.out.println("---------------------------------------------");
                System.out.print("    ,  F/f    ,        :");
                String s = scan.next();
                if(s.equals("f") || s.equals("F")){
                    //    ,      
                    System.out.println("    ,ヾ( ̄▽ ̄)Bye~Bye~");
                    System.exit(0);
                }
                break;
            case 3:
                boolean flag3 = true;
                while(flag3){
                    System.out.print("            :");
                    String stuno = scan.next();
                    //      
                    int i = 0;
                    for(; i < count; i++){
                        if(students[i][0].equals(stuno)){
                            //        ,     i     ,          
                            for(int j = i; j < count; j++){
                                students[i] = students[i+1];
                            }
                            
                            //    ,  for  
                            System.out.println("    ,  F/f    ,        :");
                            s = scan.next();
                            if(s.equals("f") || s.equals("F")){
                                //    ,      
                                System.out.println("    ,ヾ( ̄▽ ̄)Bye~Bye~");
                                System.exit(0);
                            }
                            //  -1
                            count--;
                            //    
                            flag3 = false;
                            break;
                        }
                    }
                    if(i == count){
                        //     
                        System.out.println("       "+stuno+"   ,  r/R      ,  F/f    ,        :");
                        s = scan.next();
                        if(s.equals("f") || s.equals("F")){
                            //    ,      
                            System.out.println("    ,ヾ( ̄▽ ̄)Bye~Bye~");
                            System.exit(0);
                        }else if(!s.equals("r") && !s.equals("R")){
                            //    ,    
                            flag3 = false;
                        }
                    }
                }
                break;
            case 4:
                boolean flag2 = true;
                while(flag2){
                    System.out.print("            :");
                    String stuno = scan.next();
                    //      
                    int i = 0;
                    for(; i < count; i++){
                        if(students[i][0].equals(stuno)){
                            //    ,     
                            System.out.print("       :");
                            String name = scan.next();
                            System.out.print("       :");
                            String age = scan.next();
                            System.out.print("       :");
                            String gender = scan.next();
                            System.out.print("       :");
                            String telno = scan.next();
                            //       (  )
                            students[i] = new String[]{stuno,name,age,gender,telno};
                            System.out.print("    ,  F/f    ,        :");
                            s = scan.next();
                            if(s.equals("f") || s.equals("F")){
                                //    ,      
                                System.out.println("    ,ヾ( ̄▽ ̄)Bye~Bye~");
                                System.exit(0);
                            }
                            //    ,  wile  ,    
                            flag2 = false;
                            //  for  (  ,       )
                            break;
                        }
                    }
                    if(i == count){
                        //     
                        System.out.println("       "+stuno+"   ,  r/R      ,  F/f    ,        :");
                        s = scan.next();
                        if(s.equals("f") || s.equals("F")){
                            //    ,      
                            System.out.println("    ,ヾ( ̄▽ ̄)Bye~Bye~");
                            System.exit(0);
                        }else if(!s.equals("r") && !s.equals("R")){
                            //    ,    
                            flag2 = false;
                        }
                    }
                }
                break;
            case 5:
                System.out.println("    ,ヾ( ̄▽ ̄)Bye~Bye~");
                //      
                System.exit(0);
                break;
            default:
                System.out.println("    ,     :");
            }
        }
    }
}