zoukankan      html  css  js  c++  java
  • java if与for循环的题

    //打印一个4*5的空心长方形
            /*
            for (int i = 0; i < 5;i++ ) {
                if (i == 0 | i == 4) {
                    System.out.println("*****");
                } else {
                    System.out.println("*   *");
                }
                
            }  
            */
            //打印一个4*5的长方形
            /*
            for (int i = 0; i < 5;i++ ) {
                for (int j = 0; j < 4;j++ ) {
                    System.out.print("*");
                }
                System.out.println(" ");
            }  
            */
            
            //1-100以内前5个能被3整除的整数
            /*
            int a=0;
            for (int j = 1; j <= 100; j++ ) {
                if (j%3==0) {
                    System.out.println(j);
                    a++;
                    if (a==5) {
                        break;
                    }
                }
            }  */

            
            //101~200之间的质数
            /*
            for (int h = 101;h <= 200; h++ ) {
                int a = 0;
                for (int g = 2;g < h;g++ ) {
                    if (h % g == 0) {
                    a=1;
                    }
                }
                if (a == 0) {
                    System.out.println(h);
                }
            }
            */

  • 相关阅读:
    十二月读书笔记2
    11.23
    javascript设计模式之工厂模式
    JavaScript Error:unterminated comment
    文本节点克隆cloneNode知多少
    分治法求第k小元素(vc++)
    dos下利用SMTP、POP3协议发送邮件的过程
    javascript设计模式之单体模式
    js实现无干扰阴影效果,简单好用(附文件下载)
    javascript设置css属性
  • 原文地址:https://www.cnblogs.com/bkyljk/p/7830779.html
Copyright © 2011-2022 走看看