资源描述:
《c语言练习题(exercises in c language)》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、c语言练习题(ExercisesinClanguage)Program1Title:1,2,3,4numbers,threedigitnumbercanbecomposedwitheachotherandnotrepeatthenumber?Howmucharethey?1.programanalysis:canfillat100,ten,anumberis1,2,3,4.Thenremovethearrangementdoesnotmeettheconditionwhichallarranged.2.progr
2、amsourcecode:(main){Inti,J,k;Printf("");For(i=1;i<5;i++)/*three*followingheavycycleFor(j=1;j<5;j++)For(k=1;k<5;k++){If(I=k&&i=j&&j=k!!!)toensureI,J,K/*threedifferent.Printf("%d,%d,%d",I,J,K);}}==============================================================
3、[program2]Title:corporatebonusesbasedonprofits.Profit(I)lessthanorequalto100thousandyuan,bonus10%;profitmorethan100thousandyuan,lessthan200thousandyuan,100thousandyuanlessthanthepartofthe10%Commission,morethan100thousandyuan,plus7.5%to200thousandcocoa;400thou
4、sand,morethan200thousandyuan,theCommission5%;400thousandto600thousandwhenmorethan400thousandyuan,theCommission3%;600thousandto1million,morethan600thousandyuan,totheCommissionof1.5%,higherthan1millionyuan,morethan1millionyuanpartofthe1%Commission,monthlyprofit
5、sfromthekeyboardinputI,seekthetotalnumberofbonuses?1.programanalysis:pleaseuseafewaxestoboundaries,positioning.Notethatthedefinitionneedstodefineintegergrowthbonus.2.programsourcecode:(main){Longinti;Intbonus1,bonus2,bonus4,bonus6,bonus10,bonus;Scanf("%ld",&i
6、);Bonus1=100000*0.1;bonus2=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)B
7、onus=bonus4+(i-400000)*0.03;Elseif(i<=1000000)Bonus=bonus6+(i-600000)*0.015;ElseBonus=bonus10+(i-1000000)*0.01;Printf("bonus=%d",bonus);}==============================================================[program3]Title:aninteger,plus100,isaperfectsquarenumber,plu
8、s168isacompletesquarenumber,whatisthenumber?1.programanalysis:judgmentinlessthan100thousand,thenumberofthefirstand100aftertheroot,thenthenumberofplus268afterprescribing,ifafterprescribing