Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/eclipse/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用循环在java中打印图像/模式_Java_Eclipse_Loops - Fatal编程技术网

使用循环在java中打印图像/模式

使用循环在java中打印图像/模式,java,eclipse,loops,Java,Eclipse,Loops,写课堂练习。此类必须使用循环打印出以下内容 图画在main方法中编写代码。 第一张图片: / \\ /// \\\\ ///// \\\\\\ /////// / \\ /// \\\\ ///// \\\\\\ /////// 这是我目前掌握的代码: for(int a=1; a<=7; a=a+2){ for(int i=1; i<=a; i++) System.out.print("/"); System.out.println(

写课堂练习。此类必须使用循环打印出以下内容 图画在main方法中编写代码。 第一张图片:

/ \\ /// \\\\ ///// \\\\\\ /////// / \\ /// \\\\ ///// \\\\\\ /////// 这是我目前掌握的代码:

for(int a=1; a<=7; a=a+2){  
    for(int i=1; i<=a; i++)
        System.out.print("/");
    System.out.println(" ");
    for(int c=0; c<a; c=c+2)
        System.out.print("\\\\");
    System.out.println(" ");
}
for(inta=1;a试试这个:

for (int j=1 ; j<8 ; j++){
    for(int k=0 ; k<j ; k++){
        // checking if row number is Even/Odd to print '\' or '/'
        System.out.print((j%2 == 0)? "\\" : "/");
    }
    System.out.println();
}

for(int j=1;j我假设您刚刚开始学习编程,下面是您的代码:

public class LoopPractice {

    public static void main(String[] args) {
        for(int counter = 0; counter<7; counter++){

            for(int times=0;times<=counter;times++){

                if(counter%2==0){

                    System.out.print("/");

                }else{

                    System.out.print("\\");

                }
            }

            System.out.println();           
        }
    }

}
公共课堂实践{
公共静态void main(字符串[]args){
对于(int计数器=0;计数器