资源描述:
《java编程题大全(java programming questions daquan)》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、java编程题大全(JavaprogrammingquestionsDaquan)[program1]Title:classicalquestion:thereareapairofrabbits,frombirththirdmonthsfromthebirthofapairofrabbitseverymonth,thelittlerabbitgrowstothirdmonths,amonthafterbirthForrabbits,ifrabbitsdon'tdie,askthetotalnumberofrabbitspermonth?1.pro
2、gramanalysis:thelawsoftherabbitseries1,1,2,3,5,8,13,21[program2]Title:determinehowmanyprimestherearebetween101-200,andoutputallprimes.1.programanalysis:determinetheprimenumbermethod:withanumberof2tosqrtremoved(thisnumber),ifyoucanbedivisible,Itshowsthatthisnumberisnotaprimenu
3、mber,butisaprimenumber.[program3]Title:printoutallthe"narcissusnumber",theso-called"narcissusnumber"referstoathreedigit,thenumberofcubicandequaltothenumberitself.Suchas:The153isa"daffodils",becausethreetimesthreetimesthreetimes5+3153=1.1.programanalysis:theuseofforcyclecontro
4、l100-999numbers,eachdecompositionofanumberofbits,ten,100.[program4]Title:factoringapositiveintegerintoaprimefactor.Forexample:enter90andprintout90=2*3*3*5.Programanalysis:whenfactoringtheN,weshouldfirstfindaminimumprimenumber,K,andthencompletethefollowingsteps:(1)iftheprimenu
5、mberisexactlyn,theprocessoffactoringthequalityfactorisoverandprintedout.(2)ifn<>k,butncanbedivisiblebyK,youshouldprintoutthevalueofK,andusentodividethequotientofKasthenewpositiveinteger,youn,repeatthefirststep.(3)ifncannotbedivisiblebyK,usek+1asthevalueofKandrepeatthefirstste
6、p.[program5]Title:usethenestingofconditionaloperatorstocompletethisquestion:studentswithgrades>=90arerepresentedbyA,between60-89pointsbyB,below60pointsRepresentedbyC.1.programanalysis:(a>b)a:b,whichisabasicexampleoftheconditionaloperator.[program6]Entertwopositiveintegersmand
7、N,findthegreatestcommondivisorandleastcommonmultiple.1.programanalysis:theuseofrolling.[program7]Title:enteralineofcharacters,respectively,statisticsinwhichEnglishletters,spaces,numbersandothercharactersofthenumber.1.programanalysis:usewhilestatement,theconditionfortheinputch
8、aracterisnot''.[program8]Title:s=a+aa+aaa+aaaa+aa=avalue,inwhichai