50道javase练习题.pdf





《50道javase练习题.pdf》由会员分享,可在线阅读,更多相关《50道javase练习题.pdf(17页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、50道javase练习题(50道javase练习题)program 1Title:classical question:there are a pair of rabbits,bornfrom third months after birth each month a pair of rabbits,small rabbits grow up to third months later,every month anda pair of rabbits,if the rabbit does not die,What is the total number of rabbits per month
2、?1.program analysis:the number of rabbits.1,1,2,3,5,8,13,21.program 2Topic:determine the number of primes between 101-200,and theoutput of all prime numbers.1.program analysis:the method of judging prime numbers:remove 2 to sqrt(a number)with a number,if divisible,It indicates that this number is no
3、t prime,and is a primenumber.program 3Title:print out all the Narcissus numbers”,so called“narcissus number“refers to a three digit number,the numberof cubic and equal to the number itself.For example,153 isa narcissus number”,Because three times three times three times 5+3 153=1.1.program analysis:
4、use the for cycle to control 100-999numbers,each number decomposes a bit,ten bits,hundreds.program 4Title:a positive integer decomposition of the quality factor.For example:enter 90,print out 90=2*3*3*5.Program analysis:to decompose the prime factor of N,we shouldfirst find a minimum prime number k,
5、and then complete thefollowing steps:(1)if the prime number is equal to N,the process of decomposingthe prime factor is finished and printed out.(2)if n k,but n is divisible by K,the value of K shouldbe printed,and divided by N K,a positive integer as a new nyou repeat the first step.(3)if n is not
6、divisible by K,with k+1 as the value of K,repeatthe first step.program 5Title:use the nesting of conditional operators to completethis question:students with academic scores =90 points arerepresented by A,60-89 points are represented by B,and 60points are represented by C.1.program analysis:(a b)a:b
7、?This is a basic example of theconditional operator.program 6Enter two positive integers m and N,find the greatest commondivisor and least common multiple.1.program analysis:using rolling method.program 7Title:enter a line of characters,respectively,the number ofEnglish letters,spaces,numbers and ot
8、her characters.1.program analysis:using the while statement,for the inputcharacter is not n.program 8Topic:s=a+aa+aaa+aaaa+aa.A,where a is a number.Forexample,2+22+222+2222+22222(the total sum of 5 numbers),afew numbers with keyboard control.1.program analysis:the key is to calculate each item value
9、.program 9Topic:if a number is exactly equal to the sum of its factors,this number is called end of a few”.For example 6=123.programming to find all completed within 1000.program 10Topic:a ball from a free fall height of 100 meters,each landinghalf anti jump back to the original height;then fall,for
10、 itin the tenth floor,how many meters?How high is the reboundfor the tenth time?program 11Title:1,2,3,4 numbers,how many different numbers can beformed without each other and three digits?How much are they?1.program analysis:can fill at 100,ten,a number is 1,2,3,4.Then remove the arrangement does no
11、t meet the conditionwhich all arranged.program 12Title:corporate bonuses based on profits.Profit(I)less thanor equal to 10 million yuan,the bonus can be 10%;profit higherthan 10 million,less than 20 million,less than 10 million partof the 10%Commission,higher than 10 million,cocoa percentagebetween
12、20 million to 7.5%;40 million,20 million higher thanthe part the Commission,5%;40 million higher than the partbetween 40 million to 60 million,to the Commission of 3%;between 60 million to 100 million,higher than 60 million,tothe Commission of 1.5%,higher than 100 million,More than 1 million yuan pa
13、rt of the Commission by 1%,from thekeyboard input month profit I,the total amount of bonus shouldbe awarded?1.program analysis:please use a few axes to boundaries,positioning.Note that the definition needs to define integergrowth bonus.program 13Title:an integer,plus 100,is a perfect square number,p
14、lus168 is a complete square number,what is the number?1.program analysis:judgment in less than 100 thousand,thenumber of the first and 100 after the root,then the number ofplus 268 after prescribing,if after prescribing results meetthe following conditions,which is the result of.Please seethe concre
15、te analysis:program 14Enter a certain period of a day,judgment day is the first fewdays this year?1.program analysis:in March 5th,for example,should firstadd up the first two months,and then add 5 days,that is,thefirst few days of the year,special circumstances,leap yearand input month is greater th
16、an 3,need to consider more thanone day.program 15Enter three integers x,y,Z,please put the three number ofsmall to large output.1.program analysis:we try to get the smallest number on X,the first X compared with the Y,if x y will X and Y valuesof exchange,and then x and Z are compared,if x Z will X
17、andZ values of exchange,so that the minimum X.program 16Topic:the output of 9*9 formulas.1.program analysis:branches and are considered a total of 9rows 9,I control line,J control.program 17The monkey eats the peach problem:the monkey takes off severalpeaches on the first day,eats half immediately,i
18、s not addicted,eats one more second,in the morning,will eat the peachremaining half,has eaten one more.After every morning to eatthe rest of the day before a Yibanlingyi.The tenth day in themorning to eat,see only a peach.How much did you pick up forthe first day?.1.program analysis:adopt the method
19、 of reverse thinking,forward inference from.program 18Title:two table tennis team competition,each person three.A team of a,B,C three,B teams for the X,y,Z three.The listof matches has been drawn.Someone asks the players for a listof the matches.A said he is not more than x,C said he did notx,Z,prog
20、rammed to identify a list of three teams racing.1.program analysis:judge the prime number method:use a numberto remove 2 to sqrt(this number),if can be divisible,it showsthat this number is not prime,and vice versa is prime number.program 19Title:print the following pattern(diamond)*TiananmenResultT
21、iananmen*1.program analysis:first,the graphics are divided into twoparts to see,the first four lines of a rule,the latter threelines of a rule,the use of double for cycle,the first layercontrol line,the second layer control column.program 20There is a sequence of fractions:2/1,3/2,5/3,8/5,13/8,21/13
22、.And the sum of the first 20 of the series.1.program analysis:please seize the change rule between thenumerator.program 21Title:1+2!+3!+.+20!1.program analysis:this procedure is to bring the cumulativebecome a multiplicative.program 22Topic:using recursive method to find 5!.1.program analysis:recurs
23、ive formula:fn=fn 1*4!program 23Topic:there are 5 people sit together,ask the fifth personhow old?He said he was 2 years older than fourth.Ask fourthpeople age,he said that more than third people in 2 years.Askthird people,more than second people and two.Ask second people,two years older than the fi
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 50 javase 练习题

限制150内