打印1到100之间的整数,代码中采用了三种方式去实现:

public class Print1To100 {
    public static void main(String ags[]){
        int i = 0;
        System.out.println("输出1到100之间的整数:");
        /**方法一:while
         * 
         * while(i<100){
            i++;
            System.out.println(i);
        }
        */
        
        /**方法二:do-while
         * 
         * do{
            i++;
        System.out.println(i);
        }while(i<100);
         */
        /**方法三:for
         * 
         */
        for(int j=1;j<=100;j++){
            System.out.println(j);
        }
        
    }
}

 

相关文章:

  • 2021-06-15
  • 2021-07-08
  • 2021-12-03
  • 2022-12-23
  • 2022-12-23
  • 2021-09-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-01-13
  • 2022-12-23
  • 2021-08-09
  • 2021-11-30
相关资源
相似解决方案