资源描述:
《二级c上机编程答案※※a※b……题型》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、二级C上机编程答案※※A※B……题型4.Thespecifiedinputstringcontainsonlylettersand*Numbers.Writefunctionfunwiththefunctionofdeletingallthe*Numbersinthestring.Whenyouwriteafunction,youmustnotusethestringfunctionprovidedbyC.Forexample,thecontentinAstringis:****A*************,andthecontentsofthe
2、deletedstringsshouldbe:ABCDEFG.Note:partofthesourceprogramisinthefileprog1.c.Pleasedonotchangeanycontentinmainfunctionmainandanyotherfunctions,justfillinthenumberofstatementsyouwroteinthecurlybracketsoffunctionfun.【reference】Voidfun(char*a){IntI,j=0;For(I=0;a[I]!=' ';I++)If(
3、a[I]!='*')A[j+]=a[I];/*ifthecharacterisnotdeleted,then*/A[j]=' ';/*endwiththestringterminator," "*/}12.Thespecifiedinputstringcontainsonlylettersand*Numbers.Pleasewritefunctionfun.Thefunctionistodeletealltheother*Numbersinthestringexceptthe*numberofthestringleading.Whenyouw
4、riteafunction,youmustnotusethestringfunctionprovidedbyClanguage.Forexample,thecontentinthestringis:********************,andthecontentsofthestringshouldbe:*****ABCDEFG.Note:partofthesourceprogramisinthefileprog1.c.Pleasedonotchangeanycontentinmainfunctionmainandanyotherfunctio
5、ns,justfillinthenumberofstatementsyoupreparedinthecurlybracketsoffunctionfun.【reference】Voidfun(char*a){IntI=0;Char*p=a;While(*p&&*p=='*'){A[I]=*p;I++;P++;}While(*p){If(*p!='*'){A[I]=*p;I++;}P++;}A[I]=' ';}14.Theinputstringcontainsonlylettersand*Numbers.Pleasewritefunctionfu
6、n,anditsfunctionis:deletethe*numberofthetailofthestring,andthe*numberinthefrontandmiddleisnotmoved.Forexample,thecontentsofthestringis:****A*BC*DEF*G*******,afterdeletion,thecontentsofthestringshouldbe:****A***GDEFBC.Whenyouwriteafunction,youmustnotusethestringfunctionprovide
7、dbyClanguage.Note:partofthesourceprogramisinthefileprog1.c.Pleasedonotchangeanycontentinmainfunctionmainandanyotherfunctions,justfillinthenumberofstatementsyoupreparedinthecurlybracketsoffunctionfun.【reference】Voidfun(char*a){While(*a!=' ')+;A,--./*pointerapointstothetailoft
8、hestringWhile(*a=='*')A,--./*pointerapointstothelastletter*/*(a+1)='