字典翻译 问答 其它 这四道C++题目有没有人会做啊····求解1.Writeafunctionprint()thatprintsavectorofintstocout.Giveittwoarguments:astringfor"labeling"theoutputandavector.2.CreateavectorofFibonaccinumbersandprintthemusing
问题标题:
这四道C++题目有没有人会做啊····求解1.Writeafunctionprint()thatprintsavectorofintstocout.Giveittwoarguments:astringfor"labeling"theoutputandavector.2.CreateavectorofFibonaccinumbersandprintthemusing
问题描述:

这四道C++题目有没有人会做啊····求解

1.Writeafunctionprint()thatprintsavectorofintstocout.Giveittwoarguments:astringfor"labeling"theoutputandavector.

2.CreateavectorofFibonaccinumbersandprintthemusingthefunctionfromexercise1.Tocreatethevector,writeafunction,fibonacci(x,y,v,n),whereintegersxandyareints,visanemptyvector,andnisthenumberofelementstoputintov;v[0]willbexandv[1]willbey.AFibonaccinumberisonethatispartofasequencewhereeachelementisthesumofthetwopreviousones.Forexample,startingwith1and1,weget1,1,2,3,5,8,13,21,34,55,89,144,233…..Yourfibonacci()functionshouldmakesuchaseriesstartingwithitsxandyarguments.

3.Writetwofunctionsthatreversetheorderofelementsinavector.Forexample,1,3,5,7,9becomes9,7,5,3,1.Thefirstreversefunctionshouldproduceanewvectorwiththereversedsequence,leavingitsoriginalvectorunchanged.Theotherreversefunctionshouldreversetheelementsofitsvectorwithoutusinganyothervectors(hint:swap).

4.Hereisanothermathematicalproblem,wherethetrickisasmuchtodiscoverthealgorithmasitistowritethecode:writeaprogramtodisplayallpossiblepermutationsofagiveninputstring--ifthestringcontainsduplicatecharacters,youmayhavemultiplerepeatedresults.Inputshouldbeoftheformpermutestringandoutputshouldbeawordperline.

Hereisasamplefortheinput“cat”:

cat

cta

act

atc

tac

tca

陈荣华回答:
  第一题   #include   #include   #include   usingnamespacestd;   voidprint(strings,vectorp)   {   cout
点击显示
其它推荐
热门其它推荐
  • 其它