当前位置: 首页 > 图灵资讯 > 技术篇> 使用forloop-** u,t,o,n,z,x,e,f,h,k,m,y,w,w,p,q,r **

使用forloop-** u,t,o,n,z,x,e,f,h,k,m,y,w,w,p,q,r **

来源:图灵教育
时间:2025-02-18 20:56:32

u,t,t,o,n,z,x,e,f,h,k,m,y,w,p,p,q,r

package Afterfeb4;

public class foroppatern {

    public static void main(String[] args) {
        // findstar();
        // findU();
        // findT();
        // finfO();
        // findN();
        // findZ();
        // findX();
        // findparttenE();
        // findparttenF();
        // findparttenH();
        // findparttenK();
        // findpartternM();
        // findpartternY();
        // findpartternW();
        // findpartterP();
        // findpartternQ();
        findpartternR();

    }

    private static void findpartternR() {
        for (int row = 1; row <= 9; row++) {
            for (int col = 1; col <= 9; col++) {
                if (col == 1 || row == 1 && col <= 5 || col == 5 && row <= 5 || row == 5 && col <= 5 || row - col == 5)

                    System.out.print("* ");

                else
                    System.out.print("  ");

            }
            System.out.println();
        }

    }

    private static void findpartternQ() {
        for (int row = 1; row <= 9; row++) // ---
        {
            for (int col = 1; col <= 9; col++)// ||
            {
                if (col == 1 && row <= 7 || col == 7 && row <= 7 || row == 1 && col <= 7 || row == 7 && col <= 7
                        || col == row && row > 3)

                    System.out.print("* ");

                else
                    System.out.print("  ");

            }
            System.out.println();
        }

    }

    private static void findpartterP() {
        for (int row = 1; row <= 9; row++) {
            for (int col = 1; col <= 9; col++) {
                if (col == 1 || row == 1 || col == 9 && (row <= 5) || row == 5)

                    System.out.print("* ");

                else
                    System.out.print("  ");

            }
            System.out.println();
        }

    }

    private static void findpartternW() {
        for (int row = 1; row <= 9; row++) {
            for (int col = 1; col <= 9; col++) {
                if (col == 1 || col == 9 || col + row == 10 && (row >= 5) || col == row && (row >= 5))

                    System.out.print("* ");

                else
                    System.out.print("  ");

            }
            System.out.println();
        }

    }

    private static void findpartternY() {

        for (int row = 1; row <= 9; row++) {
            for (int col = 1; col <= 9; col++) {
                if (col + row == 10 && (row <= 5) || col == row && (row <= 5) || col == 5 && (row >= 5))

                    System.out.print("* ");

                else
                    System.out.print("  ");

            }
            System.out.println();
        }

    }

    private static void findpartternM() {
        for (int row = 1; row <= 9; row++) {
            for (int col = 1; col <= 9; col++) {
                if (col == 1 || col == 9 || col + row == 10 && (row <= 5) || col == row && (row <= 5))

                    System.out.print("* ");

                else
                    System.out.print("  ");

            }
            System.out.println();
        }

    }

    private static void findparttenK() {
        for (int row = 1; row <= 9; row++) {
            for (int col = 1; col <= 9; col++) {
                if (row + col == 4 || row - col == 2 || col == 1)
                    System.out.print("* ");
                else
                    System.out.print("  ");
            }
            System.out.println();
        }

    }

    private static void findparttenH() {
        for (int row = 1; row <= 9; row++) {
            for (int col = 1; col <= 9; col++) {
                if (row == 5 || col == 9 || col == 1)
                    System.out.print("* ");
                else
                    System.out.print("  ");
            }
            System.out.println();
        }

    }

    private static void findparttenF() {
        for (int row = 1; row <= 9; row++) {
            for (int col = 1; col <= 9; col++) {
                if (row == 1 || row == 5 || col == 1)
                    System.out.print("* ");
                else
                    System.out.print("  ");
            }
            System.out.println();
        }

    }

    private static void findparttenE() {
        for (int row = 1; row <= 9; row++) {
            for (int col = 1; col <= 9; col++) {
                if (row == 1 || row == 5 || row == 9 || col == 1)
                    System.out.print("* ");
                else
                    System.out.print("  ");
            }
            System.out.println();
        }

    }

    private static void findX() {
        for (int row = 1; row <= 9; row++) {
            for (int col = 1; col <= 9; col++) {
                if (col + row == 10 || col == row)
                    System.out.print("* ");
                else
                    System.out.print("  ");
            }
            System.out.println();
        }

    }

    private static void findZ() {
        for (int row = 1; row <= 9; row++) {
            for (int col = 1; col <= 9; col++) {
                if (row + col == 10 || row == 1 || row == 9)
                    System.out.print("* ");
                else
                    System.out.print("  ");
            }
            System.out.println();
        }

    }

    private static void findN() {
        for (int row = 1; row <= 9; row++) {
            for (int col = 1; col <= 9; col++) {
                if (row == col || col == 1 || col == 9)
                    System.out.print("* ");
                else
                    System.out.print("  ");
            }
            System.out.println();
        }

    }

    private static void finfO() {
        for (int row = 1; row <= 9; row++) {
            for (int col = 1; col <= 9; col++) {
                if (row == 1 || row == 9 || col == 1 || col == 9)
                    System.out.print("* ");

                else
                    System.out.print("  ");

            }
            System.out.println();
        }

    }

    private static void findT() {
        for (int row = 1; row <= 9; row++) {
            for (int col = 1; col <= 9; col++) {
                if (row == 1 || col == 5)
                    System.out.print("* ");
                else {
                    System.out.print("  ");

                }
            }
            System.out.println();
        }
    }

    private static void findU() {

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

    }

    private static void findstar() {
        for (int row = 1; row <= 9; row++) {
            for (int col = 1; col <= 9; col++) {
                System.out.print("* ");
            }
            System.out.println("  ");
        }

    }

}

以上是使用forlopo-** u,t,o,n,z,x,e,f,h,k,m,y,w,w,p,q,r **详情请关注图灵教育的其他相关文章!

上一篇:

ML新生部署指南

下一篇:

返回列表