2017年9月30日

猴子吃桃问题:猴子第一天摘下若干个桃子,当即吃了一半,还不瘾,又多吃了一个 第二天早上又将剩下的桃子吃掉一半,又多吃了一个。以后每天早上都吃了前一天剩下的一半零一个。到第10天早上想再吃时,见只剩下一个桃子了。求第一天共摘了多少。

摘要: public static void main(String args[]){ int x=1; for(int x=1;x<=9;x++){ x=(x+1)*2; } System.out.println(x); } 阅读全文

posted @ 2017-09-30 21:46 JETIME庚 阅读(22599) 评论(0) 推荐(1) 编辑

一球从100米高度自由落下,每次落地后反跳回原高度的一半;再落下,求它在 第10次落地时,共经过多少米?第10次反弹多高?

摘要: public static void main(String args[]){ int h=100; double sum=100; for(int i=1;i<=10;i++){ h/=2; sum+=h; } System.out.println(sum); } 阅读全文

posted @ 2017-09-30 21:42 JETIME庚 阅读(544) 评论(0) 推荐(0) 编辑

判断读入的年份是否为闰年,并输出1999~2999年中所有的闰年。 判断闰年的方法:能被4整除,但不能被100整除;或可以被400整除。

摘要: public static void main(String args[]){ for(int year=1999;year<2999;year++){ if(year%4==0 && year%100!=0 || year%400){ System.out.println(year); } } } 阅读全文

posted @ 2017-09-30 21:39 JETIME庚 阅读(1286) 评论(0) 推荐(0) 编辑

求1+2!+3!+...+20!的和

摘要: public static void main(String args[]){ long f=1; long sum=0; for(int i=0;i<=20;i++){ f*=i; sum+=f; } System.out.println(sum); } 阅读全文

posted @ 2017-09-30 21:34 JETIME庚 阅读(192) 评论(0) 推荐(0) 编辑

一个整数,它加上100后是一个完全平方数,再加上168又是一个完全平方数,请问该数是多少?

摘要: public static void main(String args[]){ for(int x=1;x<=10000;x++){ if(Math.sqrt(x+100)%1==0) if(Math.sqrt(x+268)%1==0) System.out.println(x); } } 阅读全文

posted @ 2017-09-30 21:27 JETIME庚 阅读(371) 评论(0) 推荐(0) 编辑

有1、2、3、4个数字,能组成多少个互不相同且无重复数字的三位数,都是多少?

摘要: public static void main(String args[]){ for(int i=1;i<=4;i++){ for(int j=1;j<=4;j++){ for(int k=1;k<=4;k++){ if(i! = j && i !=k && j !=k){ System.out. 阅读全文

posted @ 2017-09-30 21:23 JETIME庚 阅读(307) 评论(0) 推荐(0) 编辑

九九乘法表

摘要: public static void main(String args[]){ for(int i=0;i<=9;i++){ for(int j=0;j<=i;j++){ System.out.print( i * j +" = "+i*j+"\t"); } System.out.println() 阅读全文

posted @ 2017-09-30 21:16 JETIME庚 阅读(134) 评论(0) 推荐(0) 编辑

导航