50道javase练习题50道javase练习题docx.docx

上传人:b****7 文档编号:9525048 上传时间:2023-02-05 格式:DOCX 页数:11 大小:19.65KB
下载 相关 举报
50道javase练习题50道javase练习题docx.docx_第1页
第1页 / 共11页
50道javase练习题50道javase练习题docx.docx_第2页
第2页 / 共11页
50道javase练习题50道javase练习题docx.docx_第3页
第3页 / 共11页
50道javase练习题50道javase练习题docx.docx_第4页
第4页 / 共11页
50道javase练习题50道javase练习题docx.docx_第5页
第5页 / 共11页
点击查看更多>>
下载资源
资源描述

50道javase练习题50道javase练习题docx.docx

《50道javase练习题50道javase练习题docx.docx》由会员分享,可在线阅读,更多相关《50道javase练习题50道javase练习题docx.docx(11页珍藏版)》请在冰豆网上搜索。

50道javase练习题50道javase练习题docx.docx

50道javase练习题50道javase练习题docx

50道javase练习题(50道javase练习题)

[program1]

Title:

classicalquestion:

thereareapairofrabbits,bornfromthirdmonthsafterbirtheachmonthapairofrabbits,smallrabbitsgrowuptothirdmonthslater,everymonthandapairofrabbits,iftherabbitdoesnotdie,

Whatisthetotalnumberofrabbitspermonth?

1.programanalysis:

thenumberofrabbits・

1,1,2,3,5,&13,21…

[program2]

Topic:

determinethenumberofprimesbetween101-200,andtheoutputofallprimenumbers・

1.programanalysis:

themethodofjudgingprimenumbers:

remove2tosqrt(anumber)withanumber,ifdivisible,

Itindicatesthatthisnumberisnotprime,andisaprimenumber・

[program3]

Title:

printoutallthe"Narcissusnumbers",socalled''narcissusnumber"referstoathreedigitnumber,thenumberofcubicandequaltothenumberitself.Forexample,"153〃isanarcissusnumber,

Becausethreetimesthreetimesthreetimes5+3153=1.

1.programanalysis:

usetheforcycletocontrol100-999numbers,eachnumberdecomposesabit,tenbits,hundreds・

[program4]

Title:

apositiveintegerdecompositionofthequalityfactor・Forexample:

enter90,printout90=2*3*3*5・

Programanalysis:

todecomposetheprimefactorofN,weshouldfirstfindaminimumprimenumberk,andthencompletethefollowingsteps:

(1)iftheprimenumberisequaltoN,theprocessofdecomposingtheprimefactorisfinishedandprintedout.

(2)ifn<>k,butnisdivisiblebyK,thevalueofKshouldbeprinted,anddividedbyNK,apositiveintegerasanewnyourepeatthefirststep・

(3)ifnisnotdivisiblebyK,withk+1asthevalueofK,repeatthefirststep・

[program5]

Title:

usethenestingofconditionaloperatorstocompletethisquestion:

studentswithacademicscores>=90pointsarerepresentedbyA,60-89pointsarerepresentedbyB,and60pointsarerepresentedbyC・

1.programanalysis:

(a>b)a:

b?

Thisisabasicexampleoftheconditionaloperator・

[program6]

EntertwopositiveintegersmandN,findthegreatestcommondivisorandleastcommonmultiple・

1.programanalysis:

usingrollingmethod・

[program7]

Title:

enteralineofcharacters,respectively,thenumberofEnglishletters,spaces,numbetsandothercharacters・

1.programanalysis:

usingthewhilestatement,fortheinputcharacterisnot,\n.

[program8]

Topic:

s=a+aa+aaa+aaaa+aa・・・A,whereaisanumber・Forexample,2+22+222+2222+22222(thetotalsumof5numbers),afewnumberswithkeyboardcontro1.

1.programanalysis:

thekeyistocalculateeachitemvalue・

[program9]

Topic:

ifanumberisexactlyequaltothesumofitsfactors,thisnumberiscalled"endofafew〃.Forexample6=123・programmingtofindallcompletedwithin1000.

[program10.

Topic:

aballfromafreefallheightof100meters,eachlandinghalfantijumpbacktotheoriginalheight;thenfall,foritinthetenthfloor,howmanymeters?

Howhighisthereboundforthetenthtime?

[program11_

Title:

1,2,3,4numbers,howmanydifferentnumberscanbeformedwithouteachotherandthreedigits?

Howmucharethey?

1.programanalysis:

canfillat100,ten,anumberis1,2,3,4.Thenremovethearrangementdoesnotmeettheconditionwhichallarranged・

[program12_

Title:

corporatebonusesbasedonprofits・Profit(I)lessthanorequalto10millionyuan,thebonuscanbe10%;profithigherthan10million,lessthan20million,lessthan10millionpartofthe10%Commission,higherthan10million,cocoapercentagebetween20millionto7.5%;40million,20millionhigherthantheparttheCoinmission,5%;40millionhigherthanthepartbetween40millionto60million,totheCommissionof3%;

between60millionto100million,higherthan60million,totheCommissionof1.5%,higherthan100million,

Morethan1millionyuanpartoftheCommissionby1%,fromthekeyboardinputmonthprofitI,thetotalamountofbonusshould

beawarded?

1.programanalysis:

pleaseuseafewaxestoboundaries,positioning.Notethatthedefinitionneedstodefineintegergrowthbonus・

[program13.

Title:

aninteger,plus100,isaperfectsquarenumber,plus168isacompletesquarenumber,whatisthenumber?

1.programanalysis:

judgmentinlessthan100thousand,thenumberofthefirstand100aftertheroot,thenthenumberofplus268afterprescribing,ifafterprescribingresultsmeetthefollowingconditions,whichistheresultof.Pleaseseetheconcreteanalysis:

[program14.

Enteracertainperiodofaday,judgmentdayisthefirstfewdaysthisyear?

1.programanalysis:

inMarch5th,forexample,shouldfirstaddupthefirsttwomonths,andthenadd5days,thatis,thefirstfewdaysoftheyear,specialcircumstances,leapyearandinputmonthisgreaterthan3,needtoconsidermorethanoneday.

[program15.

Enterthreeintegersx,y,Z,pleaseputthethreenumberofsmalltolargeoutput.

1.programanalysis:

wetrytogetthesmallestnumberonX,thefirstXcomparedwiththeY,ifx>ywillXandYvaluesofexchange,andthenxandZarecompared,ifx>ZwillXandZvaluesofexchange,sothattheminimumX.

[program16_

Topic:

theoutputof9*9formulas・

1.programanalysis:

branchesandareconsideredatotalof9rows9,Icontrolline,Jcontro1.

[program17_

Themonkeyeatsthepeachproblem:

themonkeytakesoffseveralpeachesonthefirstday,eatshalfimmediately,isnotaddicted,eatsonemoresecond,inthemorning,willeatthepeachremaininghalf,haseatenonemore・AftereverymorningtoeattherestofthedaybeforeaYibanlingyi.Thetenthdayinthemorningtoeat,seeonlyapeach・Howmuchdidyoupickupforthefirstday?

1.programanalysis:

adoptthemethodofreversethinking,forwardinferencefrom・

[program18_

Title:

twotabletennisteamcompetition,eachpersonthree・Ateamofa,B,Cthree,BteamsfortheX,y,Zthree・Thelistofmatcheshasbeendrawn.Someoneaskstheplayersforalistofthematches・Asaidheisnotmorethanx,Csaidhedidnotx,Z,programmedtoidentifyalistofthreeteamsracing・

1.programanalysis:

judgetheprimenumbermethod:

useanumbertoremove2tosqrt(thisnumber),ifcanbedivisible,itshowsthatthisnumberisnotprime,andviceversaisprimenumber・

[program19_

Title:

printthefollowingpattern(diamond)

*

***

Tiananmen

Result

Tiananmen

***

*

1.programanalysis:

first,thegraphicsaredividedintotwopartstosee,thefirstfourlinesofarule,thelatterthreelinesofarule,theuseofdoubleforcycle,thefirstlayercontrolline,thesecondlayercontrolcolumn.

Thereisasequenceoffractions:

2/1,3/2,5/3,8/5,13/8,21/13・・・Andthesumofthefirst20oftheseries.

1.programanalysis:

pleaseseizethechangerulebetweenthenumerator・

[program21_

Title:

1+2!

+3!

+...+20!

1.programanalysis:

thisprocedureistobringthecumulativebecomeamultiplicative・

[program22]

Topic:

usingrecursivemethodtofind5!

1.programanalysis:

recursiveformula:

fn二fn_1*4!

[program23]

Topic:

thereare5peoplesittogether,askthefifthpersonhowold?

Hesaidhewas2yearsolderthanfourth・Askfourthpeopleage,hesaidthatmorethanthirdpeoplein2years・Askthirdpeople,morethansecondpeopleandtwo.Asksecondpeople,twoyearsolderthanthefirstpersonsaid・Finallyaskedthefirstman,hesaid,10yearsold.Howbigarefifthpeople?

1.programanalysis:

usingtherecursivemethod,recursiveand

recursivebacksteppingisdividedintotwostages・Ifyouwanttoknowtheageoffifthpeople,youneedtoknowtheageofthefourthperson,andinturn,pushtothefirstperson(10yearsold),andthenpushback・

[program24]

Title:

giveanomorethan5positiveintegers,requirements:

first,askitisafewdigits,two,reverseprintoutyourfigures・

[program25]

Title:

a5digit,itisnotapalindromejudgment・That12321isapalindrome,abitandbitthesametenmillion,withthousandsofthesame・

[program26]

Title:

enterthefirstletteroftheweektodeterminewhatdayitis.Ifthefirstletteristhesame,thencontinuetojudgethesecondletter・

1.programanalysis:

usingthesituationstatementisbetter,ifthefirstletteristhesame,thenjudgetousethesituationstatementorifsentencetodeterminethesecondletters・

[program27.

Title:

seekingprimeswithin100

Title:

sorting10numbers

1.programanalysis:

canusetheselectionmethod,from9monthsafterthecomparisonprocess,selectaminimumexchangewiththefirstelement,thenextanalogy,withsecondelementsand8Comparisonandexchange・

[program29]

Topic:

finda3*3matrixanddiagonalelements

1.programanalysis:

usedoubleforcyclecontrolinputtwo-dimensionalarray,andthenaccumulatea[i][i]output・

[program30.

Topic:

asortedarray.Nowenteranumber,accordingtotherequirementsoftheoriginallawitisinsertedintothearray.

1.programanalysis:

firstdeterminewhetherthenumberisgreaterthanthelastnumber,andthenconsidertheinsertionofthenumberofthemiddle,afterinsertingtheelementafterthenumber,followedbyaposition・

[program31_

Title:

outputanarrayinreverseorder・1.programanalysis:

thefirstandthelastexchange.

Topic:

takeanintegerafromtherightendofthebeginningofthe4~7.

Programanalysis:

thiscanbeconsidered:

(1)moveato4bitfirst・

(2)tosetupalowof4for1,therestofthenumber0.Available〜(〜0<<4)

(3)carryontheabovetwooperations・

[program33.

Title:

printYangHuitriangle(printout10linesasshownbelow)

1.programanalysis:

One

11

121

14641

15101051[program34]

Topic:

enterthenumber3A,B,C,accordingtothesequenceofoutput・

1.programanalysis:

usingpointermethod・

[program35]

Theinputarray,th

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 职业教育 > 其它

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1