国家计算机二级c语言历年上机真题及基础知识[1].docx

国家计算机二级c语言历年上机真题及基础知识[1].docx

第 PAGE 第 PAGE #页共37页 第一套 1?填空题 请补充main函数,该函数的功能是:从键盘输入一个字符串并保存在字符 沏中,把字 符串stM中下标为偶数的字符保存在字符串 毗中并输出。例如,当 str仁cdefghij,贝I」 str2= cegi o 注意:部分源程序给出如下。 请勿改动主函数main和其他函数中的任何内容,仅在函数伽()的横线上填入所编写的若 干表达式或语句。 试题程序: #i ncl udevstdi o.h #i ncl udevconi o.h #defi ne LEN 80 mai n() { char str1[LEN],str2[LEN]; char *p1= str1 ,*p2=str2; int i=0,j=0; clrscr(); pri ntf(HEnter the stringAn1); scanf( [l ]); pri ntf(,,***the ori gial string***\nM); while(*(p1+j)) { pri ntfC [2] \*(p1+j)); j++; } for(i=0;ij;i+=2) *p2++=*(str1+i); *p2=,\0,; pri ntf(M\nThe new stri ng i s:%s\n, 【3 ]); } 答案及评析: —— 〃 %s // ,str1 [

文档评论(0)

1亿VIP精品文档

相关文档