资源描述:
《温州大学c语言历年期中考试题目精选及解答(selected questions and answers of c language midterm examination in wenzhou university)》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、温州大学c语言历年期中考试题目精选及解答(SelectedquestionsandanswersofClanguagemidtermexaminationinWenzhouUniversity)A-thefirstquestionsquare(20points)ProblemdescriptionGivenacharacter,outputasquarewiththelengthof4bythischaracter.inputThereisonlyonelineforinput,andtheline
2、hasonlyonecharacter.outputOutputasquarewithasideof4,andthefoursidesofthesquarearemadeofinputcharacters.Theinnerpartofthesquareismadeupofspaces.Inputsamplecolumn*sampleoutputThe********The****Theansweris"homework"or"experiment***************************
3、***X********************************************************************************************************B-secondquestionparityand(20points)ProblemdescriptionGivennpositiveintegers,findthesumofoddandevennumbersintheseintegers.inputTherearemultiplese
4、tsoftestdata.ThefirstrowisanintegerT,indicatingthatthereisTgrouptestdata.Eachtestdatahas2lines.Thefirstlineisapositiveintegern.Thesecondlinehasnpositiveintegersseparatedbyspaces.outputTheoutputhasTrows,twointegersperline,separatedbyaspacebetweeninteger
5、s.Thesetwointegertablesrepresenttheoddandevennumbersofthecorrespondingtestdatablocks.InputsamplecolumnTwoFour1234Six163479sampleoutput462010*******************************************************************************************#includeMain
6、(){Int,t,N,x,I,J,sumeven,sumodd;Scanf("%d",&t);For(i=1;i<=t;i++){Scanf("%d",&n);Sumeven=sumodd=0;For(j=1;j<=n;j++){Scanf("%d",&x);If(x%2==0)Sumeven=sumeven+x;ElseSumodd=sumodd+x;}Printf("%d%d","sumodd","sumeven");}}***********************************
7、********************************************************C-fifthquestionsencrypted10points)ProblemdescriptionGivenalineoftext,thelineisencryptedandoutput.Theencryptionalgorithmhereisverysimple:lowercaselettersa,B,C,...,Zinto1,2,3,andafter26output.Thecap
8、itallettersA,B,C,...,Zareconvertedto27,28,29,...52,andallothercharactersremainunchanged.inputTheinputhasseverallinesthatareprocessedtotheendofthefile.outputEncrypttheinputtextandoutputit.InputsamplecolumnHello,Welcometoc!sampleoutput345