当前位置 :
这四道C++题目有没有人会做啊····求解1.Writeafunctionprint()thatprintsavectorofintstocout.Giveittwoarguments:astringfor"labeling"theoutputandavector.2.CreateavectorofFibonaccinumbersandprintthemusing
1人问答
问题描述:

这四道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
最新更新
优秀其它推荐
PC端 | 移动端 | mip端
字典翻译(zidianfy.com)汇总了汉语字典,新华字典,成语字典,组词,词语,在线查字典,中文字典,英汉字典,在线字典,康熙字典等等,是学生查询学习资料的好帮手,是老师教学的好助手。
声明:本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
电话:  邮箱:
Copyright©2009-2021 字典翻译 zidianfy.com 版权所有 闽ICP备2022014709号-7
lyric 頭條新聞