zoukankan      html  css  js  c++  java
  • do-while

    /**
     *  需求:基本练习,do-while
     *  思路:略
     *   
     *  步骤:略
     */public class Demo_1{
        public static void main(String[] arge) {
            int x=1;
      do{
          System.out.println("x="+x);
          x++;
          }
    while(x<1);
        }
    }


    while


    /**
     *  需求:基本练习,do-while
     *  思路:略
     *   
     *  步骤:略
     */
    public class Demo_1{
        public static void main(String[] arge) {
            int y=0;
            while(y<1){
                System.out.println("y="+y);
                y++;
            }
        }
    }


    两者的区别在于第一圈循环时,while是判断循环条件的,再循环,而do-while 则是先执行后判断,所以,第二个程序先打印10,然后I++然后跳出循环。
    This moment will nap, you will have a dream; but this moment study, you will interpret a dream.
  • 相关阅读:
    Tarjan-割点&桥&双连通
    树状数组
    loli的搜索测试-5
    思维题
    生成树
    贪心
    loli的搜索测试-4
    树链剖分
    基于AHK的上课自动签到
    用列表实现栈
  • 原文地址:https://www.cnblogs.com/mawenqi-barry/p/7604782.html
Copyright © 2011-2022 走看看