<span style="font-size:18px;"> 百文买百鸡:
Scanner input=new Scanner (System.in);
int ways=1,k=0;
for(int i=0;i<=20;i++){
for(int j=0;j<=33;j++){
k=100-i-j;
if(k%3==0&&5*i+3*j+k/3==100){
System.out.println("买法"+ ways++ );
System.out.println("公鸡有:"+i+"母鸡有:"+j+"雏鸡有:"+k);
}
}
}
//*****鸡兔同笼
//chookNum+rabbit=35;
//2*chookNum+4*rabbitNum=94;
//鸡的数量chookNum的范围是0<=chookNum<=35,利用循环结构实现。
/*int chookNum;
int rabbitNum;
for(chookNum=0;chookNum<=35;chookNum++){
rabbitNum=35-chookNum;
if(2*chookNum+4*rabbitNum==94){
System.out.println("鸡有"+chookNum+"只");
System.out.println("兔有"+rabbitNum+"只");
}
}</span>
<span style="font-size:18px;">************************************************************************************* Scanner input =new Scanner (System.in);
int ji=0;
int tu=0;
for(int i=0;i<=35;i++){
for(int j=0;j<=35-i;j++){
if(i+ji==35&&i*2+ji*4==94){
ji=i;
tu=j;
System.out.println("鸡有 " +ji+ "只,兔子有 " +tu+ " 只");
}
}
}
</span>
<span style="font-size:18px;">**********************************************************************************
回文数:
Scanner input = new Scanner(System.in);
System.out.println("请输入一个五位数");
int shu = input.nextInt();
if (shu / 10000 == shu % 10 && shu / 1000 % 10 == shu / 10 % 10) {
System.out.println("回文数!");
} else {
System.out.println("输入错误!");
}
</span>
转载请注明原文地址: https://ju.6miu.com/read-1126123.html