资源描述:
《ACM第二学期题目报告》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、开放性实验ACM部分实验报告目录1057Undercut21078PalindromeNumbers61195BlowingFuses814892Axmodn=1151657Goldbach'sConjecture211755ClayBully241813Biker'sTripOdometer272104LettheBalloonRise322105NumberSequence352208ToandFro37ZOJProblemSet・10571057UndercutTimeLimit:1SecondMemoiyLimit:32
2、768KBUndercutisacardgamewheretwoplayerseachhavefivecardsnumberedonethroughfive.Ateachround,eachplayerselectsacard,thensimultaneouslyrevealsit.IfthecardsawofequalYa]ue,thaeisnoscorEOtherwise,therearetwocases:thetwocardsareiscalledanundercut),orthecardsaremorethanonepo
3、intapartInthelattercase,thepersonreyeaHlargerofthecardsgetsthenumberofpointsonthelargercard.Inthecaseofanundercuttheplayerwiththelowercard_getsthesumoftheJwocards.Thecxccntionf]tothisiswhenthecardsare1and2,inwhichcasetheplayerwiththelowercardgets6points(insteadofonly
4、3points).Aftereachround,thecardsarereturnedtothehandsandtheyplayanotherround.Forexample,ifthereare5roundsandplayerAplays(inthisorder)5,3,1,3,5andplayerBplays3,3,3,3,4,thenthescoringforeachroundwouldbe:Agets5points,nopoints,Bgets3points,nopoints,Bgets9points.Thetotals
5、wouldbeA:5,B:12.Inthisproblemyouwillbegivencardplaysforbothplayersandmustdeterminethefinalscores.InputTherewillbemultipleinputinstances.Eachinstancewillbeonegame.Thefirstlineofinputforagamewillbeanintegern<=20.(Avalueofn=0terminatesinput.)Thenexttwolineswilleachconta
6、innintegersbetween1and5inclusiveindicatingthecardsplayedoneachofnrounds.ThefirstlineareplayerA'scardplaysandthesecondlineareplayerB'scardplays.OutputEachinputinstanceshouldgenerateonelineofoutputoftheform:Ahasapoints.Bhasbpoints.wherethevalueofaandbareforyoutodetermi
7、ne.Ablanklineshouldseparateoutputlines.SampleInput553135333344231115550SampleOutputAhas5points.Bhas12points.Ahas0points.Bhas21points.题意:A、B玩牌,若牌的点数相同则双方均不得分,若相差一分,则牌点数较小的得分(两张点数之和),若大于一分,则点数较大者得到两张牌中点数较大的分值,一个例外情况,当牌点数为1、2时,较低者得6分,其中牌点数在1〜5之间思路:由以上题目可得ifelse的思路,重点在于空
8、行的位置的输出,应该在第二次n的值输入后打岀空行代码:#includeintmain(){inta[21],b[21],i,sa,sb,n,j=1;scanf(K%dM,&n);while(l){sa=0;sb=0;for(i=0;i