资源描述:
《经典c语言例程个例程(classic c language routines, routines)》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、经典c语言例程39个例程(ClassicClanguageroutines,39routines)[recommendedreading]classicClanguageroutines,atotalof39routines,748495575[program1]Title:1,2,3,4numbers,howmanydifferentnumberscanbeformedwithouteachotherandthreedigits?Howmucharethey?1.,programanalysis:canfillinonehundred,ten,anumberofdigits
2、are1,2,3,4.MakeupallthepermutationsandthengoAnarrangementthatdoesnotmeettherequirements.2.programsourcecode:(main){Int,I,J,k;Printf("");For(i=1;i<5;i++)For(j=1;j<5;j++)For(k=1;k<5;k++){If(I,=k&&i,=j&&j,=k!)Printf("%d,%d,%d",I,J,K);}}[program2]Title:bonusespaidbyenterprisesarebasedonprof
3、its.Whentheprofit(I)isbeloworequalto100thousandyuan,thebonuscanberaisedby10%;theprofitishighAt100thousandyuan,lessthan200thousandyuan,lessthan100thousandyuaninpart,accordingto10%Commission,higherthan100thousandyuaninpart,cocoamentionIn7.5%,between200thousandand400thousand,apercentageof200th
4、ousandyuanis5%Commission;between400thousandand600thousandishigher400thousandyuanpart,candeductapercentagefrom3%;between600thousandand1millionwhen,above600thousandyuanpart,candeductapercentageof1.5%,behigherthan1millionyuan,morethan1millionyuaninpart,accordingto1%Commission,fromthekeyboardin
5、putmonthprofitsI,begshouldbeawardedbonustotal?1.programanalysis:pleaseuseafewaxestoboundaries,positioning.Whendefiningthedefinition,youneedtodefinethebonusasagrowthinteger.2.programsourcecode:(main){Longinti;Int,bonus1,bonus2,bonus4,bonus6,bonus10,bonus;Scanf("%ld",&i);Bonus1=100000*0.1;bon
6、us2=bonus1+100000*0.75;Bonus4=bonus2+200000*0.5;Bonus6=bonus4+200000*0.3;Bonus10=bonus6+400000*0.15;If(i<=100000)Bonus=i*0.1;Elseif(i<=200000)Bonus=bonus1+(i-100000)*0.075;Elseif(i<=400000)Bonus=bonus2+(i-200000)*0.05;Elseif(i<=600000)Bonus=bonus4+(i-400000)*0.03;Elseif(i<=1000000)Bonus=bon
7、us6+(i-600000)*0.015;ElseBonus=bonus10+(i-1000000)*0.01;Printf("bonus=%d",bonus);}[program3]Title:aninteger,plus100,isaperfectsquare,plus168isaperfectsquarenumber.What'sthenumber?1.programanalysis:judgmentinlessthan100thousand,thenumberofthefirstand100af