版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
java練習(xí)題目(java練習(xí)題目)
[program1]
Title:classicalquestion:thereareapairofrabbits,from
birththirdmonthsfromthebirthofapairofrabbitsevery
month,thelittlerabbitgrowstothirdmonths,amonthafter
birth
Forrabbits,ifrabbitsdon'tdie,askthetotalnumberof
rabbitspermonth?
1.programanalysis:thelawsoftherabbitseries
1,1,2,3,5,8,13,21
[program2]
Title:determinehowmanyprimestherearebetween101-200,and
outputallprimes.
1.programanalysis:determinetheprimenumbermethod:with
anumberof2tosqrtremoved(thisnumber),ifyoucanbe
divisible,
Itshowsthatthisnumberisnotaprimenumber,butisaprime
number.
[program3]
Title:printoutallthe“narcissusnumber”,theso-called
“narcissusnumber"referstoathreedigit,thenumberofcubic
andequaltothenumberitself.Suchas:
The153isa“daffodils”,becausethreetimesthreetimesthree
times5+3153=1.
1.programanalysis:theuseofforcyclecontrol100-999
numbers,eachdecompositionofanumberofbits,ten,100.
[program4]
Title:factoringapositiveintegerintoaprimefactor.For
example:enter90andprintout90=2*3*3*5.
Programanalysis:whenfactoringtheN,weshouldfirstfind
aminimumprimenumber,K,andthencompletethefollowing
steps:
(1)iftheprimenumberisexactlyn,theprocessoffactoring
thequalityfactorisoverandprintedout.
(2)ifnOk,butncanbedivisiblebyK,youshouldprintout
thevalueofK,andusentodividethequotientofKasthe
newpositiveinteger,youn,repeatthefirststep.
(3)ifncannotbedivisiblebyK,usek+1asthevalueofK
andrepeatthefirststep.
[program5]
Title:usethenestingofconditionaloperatorstocomplete
thisquestion:studentswithgrades>=90arerepresentedbyA,
between60-89pointsbyB,below60points
RepresentedbyC.
1.programanalysis:(a>b)a:b,whichisabasicexampleofthe
conditionaloperator.
[program6]
EntertwopositiveintegersmandN,findthegreatestcommon
divisorandleastcommonmultiple.
1.programanalysis:theuseofrolling.
[program7]
Title:enteralineofcharacters,respectively,statisticsin
whichEnglishletters,spaces,numbersandothercharactersof
thenumber.
1.programanalysis:usewhilestatement,theconditionforthe
inputcharacterisnot''n'.
[program8]
Title:s=a+aa+aaa+aaaa+aa=avalue,inwhichaisanumber.
Forexample,2+22+222+2222+22222(thereare5numbersadded
together),
Severalnumbersareaddedwithkeyboardcontrol.
1.programanalysis:thekeyistocalculatethevalueofeach
item.
[program9]
Topic:ifanumberisexactlyequaltothesumofitsfactors,
thisnumberiscalled“endofafew”.Forexample6=123.
programmingtofindallfinishedwithin1000
Thenumberof.
[program10]
Topic:abal1fromafreefallheightof100meters,eachlanding
halfantijumpbacktotheoriginalheight;thenfall,forit
inthetenthfloor,atotalofover
Lessrice?Howhighisthetenthbounce?
[program11]
Title:1,2,3,4numbers,howmanydifferentnumberscanbe
formedwithouteachotherandthreedigits?Howmucharethey?
1.,programanalysis:canfillinonehundred,ten,anumber
ofdigitsare1,2,3,4.Makeupallpermutationsandthen
removepermutationsthatdonotmeettherequirements.
[program12]
Title:bonusespaidbyenterprisesarebasedonprofits.When
theprofit(I)isbeloworequalto100thousandyuan,thebonus
canberaisedby10%;theprofitishigherthan100thousand
yuan,lessthan200thousand
Yuan,lessthan100thousandyuaninpart,accordingto10%
Commission,higherthan100thousandyuanpart,cocoa
Commission7.5%;200thousandto400thousandbetween,higher
than200thousandyuanDepartment
Cent,candeductapercentagefrom5%;between400thousandand
600thousandwhenthepartishigherthan400thousandyuan,
candeductapercentagefrom3%;between600thousandand1
millionwhen,thepartthatishigherthan600thousandyuan
can
Deductapercentagefrom1.5%,whenhigherthan1millionyuan,
morethan1millionyuanpart,press1%deductapercentagefrom
asumofmoney,
Enterthemonthprofitfromthekeyboard,I,andaskforthe
bonus
1.programanalysis:pleaseuseafewaxestoboundaries,
positioning.Whendefiningthedefinition,youneedtodefine
thebonusasagrowthinteger.
[program13]
Title:aninteger,plus100,isaperfectsquare,plus168is
aperfectsquarenumber.What'sthenumber?
1.programanalysis:judgmentinlessthan100thousand,the
numberofthefirstand100aftertheroot,thenthenumberof
plus268afterprescribing,ifafterprescribingresultsmeet
Thefollowingconditions,thatistheresult.Pleaseseethe
concreteanalysis:
[program14]
Topic:enterayear,amonth,adate,todeterminethedayis
thefirstfewdaysoftheyear?
1.programanalysis:inMarch5th,forexample,thefirsttwo
monthsshouldbeaddedup,andthenplus5days,thatis,the
firstfewdaysoftheyear,specialcircumstances,leapyear,
and
Youneedtoconsideraddingonemoredaytothemonthwhenthe
inputisgreaterthan3.
[program15]
Enterthreeintegersx,y,Z,pleaseputthethreenumberof
smalltolargeoutput.
1.programanalysis:wewouldliketoputthesmallestnumber
ontheX,comparexwithyfirst,ifx>ywillexchangethevalue
ofXandy,andthenuseX
ComparewithZ,ifx>zwillexchangethevalueofXandZ,this
canmakexminimum.
[program16]
Topic:theoutputof9*9formulas.
1.programanalysis:branchandcolumnconsidered,atotalof
91ines,9columns,Icontrol1ine,Jcontrolcolumn.
[program17]
Question:monkeyseatpeachesproblem:monkeyspickedoffafew
peachesonthefirstday,immediatelyatehalf,notaddicted,
andeatasecondday,themorningwillbeleft
Thepeachatehalf,andateonemore.Everymorning,Iatethe
daybefore
TheYibanlingyia.Bythetenthmorning,whenIwantedtoeat
again,Isawonlyonepeachleft.Askforthefirstday.
1.programanalysis:reversethinking,fromthebacktoinfer.
[program18]
Title:twotabletennisteamsplay,eachwiththreeplayers.
Ateamisa,B,Cthree,teamBisx,y,Zthree.Thelistof
matcheshasbeendrawnup.Someoneto
Theteaminquiredaboutthelistofmatches.Asayshedoesn't
comparewithX,andCsayshedoesn,tcomparewithX,Z,and
askstheprogramtofindalistofthethreeteamplayers.
1.programanalysis:determinetheprimenumbermethod:with
anumberofremovalof2tosqrt(thisnumber),ifyoucanbe
divisible,itshowsthatthisnumberisnotprime,inverse
Primenumber.
[program19]
Title:printthefollowingpattern(diamond)
*
***
Tiananmen
Result
Tiananmen
***
*
1.programanalysis:first,thegraphicsaredividedintotwo
partstolookat,thefirstfourlinesofarule,thelatter
threelinesofarule,theuseofdoubleforcycle,thefirst
layerofcontrol
OK,secondlayercontrolcolumn.
[program20]
Title:thereisasequenceoffractions:2/1,3/2,5/3,8/5,
13/8,21/13...Andthesumofthefirst20oftheseries.
1.programanalysis:pleaseseizethelawofchangeofnumerator
anddenominator.
[program21]
Title:1+2,+3,...+...+20...And...
1.programanalysis:Thisprogramjustaccumulatedintoatired
ride.
[program22]
Title:usingrecursivemethodfor5!.
1.programanalysis:recursiveformula:fn=fn1*4!
[program23]
Title:5peoplesittogetherandaskhowoldarefifthpeople?
Hesaidhewas2yearsolderthanfourth.Askedtheageoffourth,
hesaidhewas2yearsolderthanthird,ask
Thirdpeople,secondyearsolderthantwo.Askedsecondpeople,
saidtwoyearsolderthanthefirstperson.Finallyaskedthe
firstman,hesaid,is10yearsold.Fifth,please
Howoldareyou?
1.programanalysis:theuseofrecursivemethod,recursive
dividedintobackpushandrecursivetwostages.Ifyouwant
toknowtheageoffifth,youmustknowtheageofthefour,
Byanalogy,pushtothefirstperson(10yearsold),thenpush
back.
[program24]
Title:toanomorethan5positiveintegers,requirements:
first,askitisafewdigits,two,thereverseprintoutyour
figures.
[program25]
Title:a5digitnumbertodeterminewhetheritispalindrome.
Thatis,12321isthepalindromenumber,thebitisthesame
asthetens,andthetenbitisthesameasthethousand.
[program26]
Title:Pleaseenterthefirstletteroftheweektodetermine
whatdayitis.Ifthefirstletteristhesame,thencontinue
tojudgethesecondletters.
1.programanalysis:itisbettertousethecasestatement.
Ifthefirstletteristhesame,thenjudgethesecondletters
withthecasestatementortheifstatement.
[program27]
Title:seektheprimenumberwithin100
[program28]
Title:sort10numbers
1.programanalysis:youcanusetheselectionmethod,thatis,
fromthelatter9comparisonprocess,selectaminimumandthe
firstelementoftheexchange,andthenextanalogy,thatis,
withthefirst
Thetwoelementsarecomparedwiththelatter8andexchanged.
[program29]
Title:thesumofthediagonalelementsofa3*3matrix
1.programanalysis:theuseofdoubleforloopcontrolinput
two-dimensionalarray,andthena[i][i]cumulativeoutput.
[program30]
Title:thereisanarrayalreadyingoodorder.Nowentera
number,theoriginallawrequiredtoinsertitintothearray.
1.programanalysis:firstdeterminewhetherthisnumberis
greaterthanthelastnumber,andthenconsidertheinsertion
ofthemiddlenumber,afterinsertingtheelementafterthe
number,
Moveonepositionbackwardinturn.
[program31]
Title:outputanarrayinreverseorder.
1.programanalysis:usethefirstoneandthelastone.
[program32]
Title:takeanintegera,startingfromtherightsideofthe
4?7bit.
Programanalysis:thiscanbeconsidered:
(1)firstmoveato4bits.
(2)setalow4bit,all1,andtheremaining0.Available
C0?4)
(3)performtheoperationsofthetwoabove.
[program33]
Title:printouttheYangHuitriangle(asktoprintout10lines,
asshownbelow)
1.programanalysis:
One
11
121
1331
14641
15101051
[program34]
Title:enter3numbersa,B,C,outputinsizeorder.
1.programanalysis:usingpointermethod.
[program35]
Title:enterthearray,thelargestwiththefirstelementof
theexchange,thesmallestwiththelastelementoftheexchange,
outputarray.
[program36]
Title:therearenintegers,sothatthefrontofthenumber
ofmovingbackwardmposition,andfinallythenumberofM
becomesthenumberofminthefront
[program37]
Topic:npersonalcircle,orderarranging.Startedfromthe
firstreport(from1to3report),whoreported3peopleout
ofthecircle,askthelasttoleave
Whowastheoriginalnumber?.
[program38]
Title:writeafunctiontofindthelengthofastring,enter
thestringinthemainfunction,andoutputitslength.
[program39]
Title:writeafunction,enterthenisevennumbers,callthe
functionfor1/2+1/4+...+l/n,whentheinputnisodd,call
thefunction
1/1+1/3+...+l/n(usingpointerfunction)
[program40]
Title:stringsorting.
[program41]
Topic:thereisapileofpeachesonthebeach,andfivemonkeys
aredivided.Thefirstmonkeydividedthepileofpeachesinto
fiveparts,onemore,andthemonkeyputmorethanone
Onethrewintotheseaandtookone.Thesecondmonkeysdivided
theremainingpeachesintofiveequally,andonemore,andit
threwonemoreintothesea
Takeone,third,fourth,fifthmonkeysdothat,andaskhowmany
peachesarethereonthebeachatleast
[program42]
Title:809*?=800*?+9*?+1?
Amongthem,therepresentativeofthetwodigit,8*,andthe
resultistwodigit,9*,andtheresultis3figures.Beg?
Representtwodigits,
And809*?Aftertheresults.
[program43]
Title:anoddnumberthatcanbecomposedof0-7.
[program44]
Title:anevennumbercanalwaysbeexpressedasthesumoftwo
primenumbers.
[program45]
Title:aprimenumbercanbedividedbyafew9
[program46]
Title:twostringconnectionprogram
[program47]
Title:readthewholenumberof7numbers(1-50),eachread
avalue,theprogramprintoutthevalueofthenumberof*.
[program48]
Title:acompanyusesapublictelephonetotransmitdata.The
dataisanintegeroffourbits.Itisencryptedduringthe
transmission.Theencryptionrulesareasfollows:eachdigit
Bothadd5,thendividethenumberbyandby10insteadofthe
number,thenexchangethefirstbitandthefourthbit,the
secondbitandthethirdbit.
[program49]
Title:howmanytimesdoesstringstringappear?
[program50]
Title:therearefivestudents,eachstudenthas3classesof
results,fromthekeyboardinputoftheabovedata(including
studentnumber,name,threeclassresults),calculated
Averageresults,originaldata,andcalculatedaveragescores
arestoredinthediskfile"stud".
1.Writeadatecalculationprogram.Designrequirements:
(choosetomakeone)
1)amonthisenteredbytheuser,andthemonthcalendaris
displayedonthescreeneveryMonday,andendsfromSundayto
Saturday.
2)enteradatebytheuserandthescreenansweriswhatday
oftheweek.
3)entertwodatesbytheuserandcalculatethedifference
betweenthetwodates.
2,enterastring,statisticsinwhichthenumberofcharacters
appear.
3.Enter3integersfromthekeyboard,andcalculatewhether
thetrianglewiththe3numbersisrighttriangle.
4,inApplettoachievethecalculatorfunction:youcan+,-
*,/fourarithmetic.
1,defineacircleclassthatincludesthemethodofcalculating
theareaofthecircleandthecircumferenceofthecircle.If
theradiusoftheinputislessthan0,acustomexceptionis
thrown.
2.Writeadivisionprogramthatrequiresthedivisorandthe
divisortobeenteredfromthekeyboard.Iftheinputdivisor
isanonnumerictypesuchas6y,theprogramautomatically
interruptsandthrowstheNumberFormatExceptionexception
withoutenteringthedivisorprogram.Iftheinputdivisoris
0,theprogramthrowstheArithmeticExceptionexception.And
usefinallytoprocessthefinalresult.
3,adesignfromthecommandline(keyboard)inputastring
program,ifthestringvalueis"123"exceptionisan
Exceptionl23(custom),anddisplaythe“123stringcausedby
abnormal
1,programmingtocreateaBoxclass,definethreevariables
acubeoflength,widthandheightinthem,andthendefinea
methodsetDemotoinitializethethreevariables,andthen
defineamethodtocalculatethevolumeofacube.Createan
objecttofindthesizeofacubeofagivensize.
2,thetitleofthemethod,setDemoconstructortoachieve
initialization.
3,programmingtocreateaPointclass,definetwovariables
ofcoordinatesofapointvalueinthem,andthendefinea
constructorinitializationastheoriginofcoordinates,and
thendefineamethodtorealizethepointmove,thendefinea
coordinatepointofthecurrentprintmethod.Andcreatean
objectverification.
4,defineaclassthatimplementstheconceptofbankaccounts,
includingvariablessuchasaccountsandbalances.Methods
includedeposits,withdrawals,andquerybalances”.Definethe
mainclass,createtheobjectoftheaccountclass,andcomplete
theappropriateoperation.
5,thedefinitionofthefollowingbasicclasses,requiresthe
realizationofinheritance:point,Cylinder,Circle,class,
cylinder,inheritancepoint,cylinder,inheritancecircle.The
circleradius,thecircleareaandthecylindervolumecanbe
calculated.
6,defineamedia(media)classthatcontainsinformationsuch
asname,author,publisher,andprice,andcanenterthis
informationfromthekeyboard.
Thencreatemediasubclasses:books(Book)andcd.
ProgrammingFibonaccisequence.TheFibonacciseriesis
definedas:
Fl=l,F2=l...
Fn=Fn-l+Fn-2(n>=3)
Tip:thekeycodeisasfollows:
F[0]=f[l]=l;
For(i=2;i<10;i++)
2.,buildanumericarray,calculatetheoddnumbersandall
theoddvalues,and.
3.usingthearraytoachievethebasicfunctionsofthequeue:
Aqueueisabasicdatastructurethatfollowstheprinciple
offirstin,firstout.Thequeueusuallysupportstwobasic
operations:put,get(to)(made),eachputoperationwillbe
anewelementinthequeuetail;eachgetoperationwillbea
newelementtogetthenextelementinthequeueatthebeginning.
Queueelementsareexpendable,andonceanelementhasbeen
obtained,itcannotbeacquiredagain.Ifthequeuehasnospace,
itisfull.Iftherearenoelementsinthequeue,thecolumn
isempty.
4.whatarethedisadvantagesofusingarrays?
(1)usingsimpleifstatementprogramming,typethreeintegers
fromthekeyboard,andthenoutputtheminorderfromsmallto
large.
(2)useif-else-ifstatementsandswitchstatementsto
determinewhichseasonamonthis,respectively.
(3)programmingenterthegradesofstudents,academic
achievements,andgivethecorrespondingachievementrange.
Setalevelof85ormore(including85points);Bclassis70
pointsormore(including70points);Cclassismorethan60
points(including60points);Dclassisbelow60points.Using
theifstatementandtheswitchstatement,respectively.
(4)usingthecontinuestatement:outputthenumbersbetween
100?300thatcannotbedivisibleby3.
(5)usethebreakstatementtoachievethecount:from1?100,
whenyoucountto78,theprogramterminates.
(6)usewhile,DO-WHILEandforstatementprogramming
respectively,seekthesumof「100.
(7)usewhile,DO-WHILEandforstatementprogramming
respectively,findoutallnarcissusnumberandoutput.The
numberofdaffodilsisthreedigits,andthecubeofitsnumbers
isequaltothethreedigititself,forexample:
371=33+73+13371isanarcissusnumber.
(8)anintegerisenteredbytheuser,andtheresultisgiven
bytheprogramtodeterminewhetheritisaprimenumberornot.
Orenterarangebytheuser,theprogramlistsalltheprime
numberswithinthatrange
(9)printthefollowingdiagramusingcyclicstatements:
*
***
Miss
xl>
ZTXZTSXTHZivXTS
Thisiswhenourteachergavethetitle,verysystematic,for
youtostudymustbeofgreathelp
sixsi*sixxlxxlxxtxxl*xlxxfxxlzxl*xl*xlxxlxxlxxlxxlzxtxxlxxlxxlxxlxxlxxfxvl*xlxxtxsixxlxxJxxlz*1*xlxxlzxtx*X*xlxxlzxl*xlxxlzxlx
ZTSZTXXjXXTSXT**T*XTXXT**TS?JXXTX*T*XTSXT**T*XTXXTX**1>XTSZTX^7^*TSXTXXTXXTXXISZTSXTXX7S**1>XT>XTXXTXXTXZjXZTS*TS
x|cx|c
1,respectively,writeApplicationandAppletprogram,display
string"HelloJava”!Welcometouse!”.
2,printyourownnamewith'.Suchas"King"isprintedas
xl*vtxxJxxlxxlxKL*xlzxL*
?THXTS*7*>TXXTSXTXXTX
**
**
x|cx|c
**
**
sL*X,L*sixvl*xlxxl>xtxxlxxlxxlxxJx
xp?*T**T*XTXXTSXT**T**T?XTXZT*
*1**1**£**1**1*xfz*1*xl*xlxsixxl*vt*xl**lz*1^xl*^1**fxsi**lz*lzxl*xlzxl*xl*si**1*xlzxlz*1*xlzxfx*1*si**1**lz*lx*1**X*xlz*X*xlz?Xz
q、*TXXT*(、*7xxTxXTXq、"、XT%XTX/、*TX*T%XT%XTX*TV*T%*TX*7*XT**Tx*T%XTX*TVXTX*T*
*1**1**1**A**lx*lzsi*xt**1**1**1**lz*lx*Ix%lxxlz%I*KIXvlx*X**XZ*1*xl*
ZT%*TX*T*ZT**TX*TX*TXZTX/、ZT**TX*T**TX*TX*TXZTX
1,usingtheBufferedReaderclassfromthekeyboardtoreceive
anintegerandarealnumber,calculatetheirsum,andthen
outputonthescreen.
Tip:thekeysentencesareasfollows:
BufferedReaderDIN=newBufferedReader(new,
InputStreamReader(System,in));
I=Integer.parselnt(din.readLine());
F=Float.parseFloat(din.readLine());
2,throughtheinterfaceinputtwointegers,thegreatest
c
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025年滬教版八年級(jí)物理下冊(cè)月考試卷含答案
- 2025年粵教滬科版選擇性必修3歷史下冊(cè)階段測(cè)試試卷含答案
- 2025年粵教新版八年級(jí)地理下冊(cè)階段測(cè)試試卷
- 2025年蘇教版七年級(jí)生物下冊(cè)月考試卷
- 遵義職業(yè)技術(shù)學(xué)院《中國古代文學(xué)與中學(xué)語文教育》2023-2024學(xué)年第一學(xué)期期末試卷
- 二零二五版木工雕刻藝術(shù)創(chuàng)作授權(quán)合同4篇
- 2025年度農(nóng)用拖拉機(jī)租賃與農(nóng)產(chǎn)品溯源合同4篇
- 二零二五年度金融行業(yè)派遣勞務(wù)安全保障合同4篇
- 2025年度屋頂綠化租賃與節(jié)能減排合同4篇
- 二零二五年倉儲(chǔ)設(shè)備采購與運(yùn)輸合同3篇
- 2024年英語高考全國各地完形填空試題及解析
- 智能養(yǎng)老院視頻監(jiān)控技術(shù)方案
- 你比我猜題庫課件
- 體育概論(第二版)課件第三章體育目的
- 無人駕駛航空器安全操作理論復(fù)習(xí)測(cè)試附答案
- 建筑工地春節(jié)留守人員安全技術(shù)交底
- 默納克-NICE1000技術(shù)交流-V1.0
- 蝴蝶蘭的簡介
- 老年人心理健康量表(含評(píng)分)
- 《小兒靜脈輸液速度》課件
- 營銷人員薪酬標(biāo)準(zhǔn)及績效考核辦法
評(píng)論
0/150
提交評(píng)論