资源描述:
《C语言题目及答案.doc》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、目录1.ClimbtheTaishanMountain(II)2.Peach3.逆序输出数列4.逆序数5.计算高度6.分解质因数7.输出数字8.ProblemB:数字之和9.换零钱10.素数求和11.求阶乘和11.ProblemF:求一批正整数中的偶数和12.统计各种字符个数13.求最大公约数14.求最大公约数15.零起点学算法101——统计字母数字等个数16.网站泄密17.老外买瓷砖18.堆瓷砖19.新年大酬宾20.定制瓷砖21.句子比较大小22.鹦鹉学舌3——C语言初学者百题大战之十三23.鹦鹉学舌2——C语言初学者百题大战之十二24.百鸡问题25.零起点学算法89——程序设计竞赛26.零
2、起点学算法89——程序设计竞赛27.ProblemA:计算数列和28.找钱问题29.Median30.素月31.输入任意N个数,求和32.多项式求和33.人口问题34.数字菱形ClimbtheTaishanMountain(II)TimeLimit:1000MSMemoryLimit:65536KTotalSubmit:753Accepted:495DescriptionLabordayiscoming.Sincetheholidayislong,Manystudentsareplanningtohaveatour.TheTaishanMountainisverybeautiful,soWan
3、gPengandhisclassmateswanttoclimbtheTaishanMountain.MountaineeringsportsisWangPeng'savocation,soheisveryexcited.Suddenly,averyamusingideacomestohim.TheTaishanMountainhasmanystairs,andhecanclimbthemountainonestepby2stairsorby1stairs.Howmanywaysdoeshehavetoclimbthemountain?Forexample,thestairsis2,hehas
4、2ways.Thefirstoneisthefirststepby1stair,andthenextstepby1stair.Andthesecondwayisonlyonestepby2stairs.InputTheinputisincludingmanytestcases.EverylineisonetestcasewithaintegernumberN(N<=40).NisthestairsoftheTaishanMountain.OutputYoushouldoutputhowmanywaysWangPengcanclimbthemountain,eachcaseoutputaline
5、.SampleInput123SampleOutput123#includeintmain(){intn,i,j,a[41];while(scanf("%d",&n)!=EOF){a[0]=1;a[1]=2;for(i=2;i<40;i++){a[i]=a[i-1]+a[i-2];}printf("%d",a[n-1]);}}PeachTimeLimit:1000MSMemoryLimit:65536KTotalSubmit:689Accepted:495DescriptionAlmostallyoungmanknowMonkeySunwhosenameisSunWuko
6、ng.Onedayhestealsmanypeachesfromthekingdomofheaven.Firstday,heateahalfofthepeaches,thenateanotheroneoftheleftpeaches.Thenextday,heateahalfoftheleftpeaches,thenanotherone.Untilthen-thday,beforeheatehefoundonlyonepeach.PleasehelpSunWukongtocalculatehowmanypeacheshetookfromthekingdomofheaven.InputThein
7、putfilecontainsoneormoretestcases,eachlineisthedaysN(1intmain()