标签:-- ++ rgs ring lag int() ati while continue
第九章 循环练习
public class *** {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int xy=0;
System.out.println("请输入等腰三角形的行数:");
xy = input.nextInt();
for(int i=0;i<xy;i++){
for(int x=0;x<xy-i;x++){
System.out.print(" ");
}
for(int y=0;y<2*i+1;y++){
System.out.print("*");
}
System.out.print("\n");
}
}
}
public class *** {
public static void main(String[] args){
int i=0;
int j =0;
int k =0;
for(i=0;i<=20;i++){
for(j=0;j<33;j++){
k = 100-i-j;
if(5*i+3*j+k/3==100){
System.out.println("公鸡:"+i+"\t\t"+"母鸡:"+j+"\t\t"+"小 鸡:"+k);
continue;
}
}
}
}
}
public class *** {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
boolean flag=false;
int count=3;
for(int i=0;i<3;i++){
System.out.println("请输入密码:");
int num=input.nextInt();
if(num==111111){
flag=true;
break;
}
count--;
System.out.println("您还有"+count+"次输入错误的机会。");
}
if(flag){
System.out.println("请输入金额:");
int money=input.nextInt();
while(money%100!=0||money<0||money>1000){
System.out.println("输入金额不合法,请重新输入:");
money=input.nextInt();
}
System.out.println("取走了"+money+"元");
}else{
System.out.println("输入错误超过3次,程序结束");
}
System.out.println("操作完成请取卡");
}
}
标签:-- ++ rgs ring lag int() ati while continue
原文地址:http://www.cnblogs.com/songziqiang-/p/6970202.html