常用:
for循环:计算次数的循环
while循环,??
输入押注
显示输入符合条件的数字
package day04;
import java.util.Scanner;
public class dowhileDemo {
public static void main(String[] args) {
// TODO 自动生成的方法存根
Scanner sc=new Scanner(System.in);
int balance =1000;
int bet;
do{
System.out.print("输入押注:");
bet=sc.nextInt();
} while ((bet<=0)||(bet>balance));
System.out.println(bet);
/*
* do...while循环
* 先执行do后面代码,再判断while后面代码的boolean类型,为true则继续循环.
*
* while循环,则是先判断后执行.
*/
}
}
/*
*
* 工作中常用:
* while(true){
* ...
* ...
* ...
* break;
* }
* */
发牌,逢N折行
package day04;
public class zhehangDemo {
public static void main(String[] args) {
// TODO 自动生成的方法存根
int i = 0;
while (i < 54) {
System.out.print(i++ % 4);//0,1,2,3,0,1,2,3,....(先对4取余,然后加1)
if (i % 4 == 0) {
System.out.println();//回车符
}
}
/*54张牌,发扑克牌,逢四(n)折行
* 输出:
* 0123
* 0123
* 0123
* 0123
* 0123
* 0123
* 0123
* 0123
* 0123
* 0123
* 0123
* 0123
* 0123
* 01
* 也可以用于麻将发牌108张,等等
*/
}
}