zoukankan      html  css  js  c++  java
  • Java小程序2(2015-8-10)

    /*
    while语句的使用、讲解
    */
    public class Test1{
     public static void main(String[] args){
      int number = 10;
      //--循环条件
      while(number>0){
       //--循环体:循环执行的语句
       System.out.println(number);
       //--条件的变化
       number--;
      } 
     }
    }

    /* do-while的讲解使用 */ public class Test2{  public static void main(String[] args){   int number = 10;

      do{    System.out.println(number);

       number--;

      }while(false);

      while(false){    //==循环体   }

     } }

    1、使用do-while单循环,打印输出10~100之间所有

    public class Test22{      

    public static void main(String [] args){                     

                  System.out.println("10-100之间能同时被5和9整除的整数有:");

                  int a=10;         

       do{                

                   if(a%5==0&&a%9==0){              

                                 System.out.println(a);}                                  

                                 a++;

               }while(a<=100);            

                /*  System.out.println("10-100之间能同时被5和9整除的整数有:");

                int a=10;          

                 while(a<=100)           {               

                             if(a%5==0&&a%9==0){             

                                              System.out.println(a);}                                

                              a++;

               }*/

      }}

    能同时被5和9整除的整数。

  • 相关阅读:
    JS 子窗口向父窗口传值
    CSS垂直居中盘点
    Javascript关于BOM与DOM详解
    css inline元素与inline-block,block元素
    CSS定位
    mysql 8+ 忘记root密码 解决方案
    php 引入其他文件中的变量
    h5 input无法输入问题 屏蔽长按事件
    关于ajax请求status 200 却进入error 回调函数或显示跨域问题的解决方案及原因
    vue 中使用 lazyload 插件 数据更图片不更新 的原因 及解决方案
  • 原文地址:https://www.cnblogs.com/Ly426/p/4717818.html
Copyright © 2011-2022 走看看