2013年计算机二级C语言上机题库三十九

考试站(www.examzz.com)   【考试站:中国教育考试第一门户】   2013年5月22日

为方便广大考生更好的复习2013年计算机二级C语言考试,查找考试辅导习题,考试站网校网校特提供了C语言上机预测题(填空题、改错题、编程题),更多模拟无纸化考试“计算机二级C语言模拟题”,供考生学习。

 填空题
  请补充main函数,该函数的功能是:从一个字符串中截取前面若干个给定字符数的子字符串。其冲,str1指向原字符串,截取后的字符串存放在str2所指的字符数组中,n中存放预截取的字符个数。
  例如,当str1=”abcdefg”,然后输入3,则str2=”abc”.
  注意:部分源程序给出如下
  仅在横线上填入所编写的若干表达式或语句,请勿改动函数中的任何内容。
  试题程序:# include <stdio.h>
  # include <conio.h>
  # define LEN 80
  main()
  {
  char str1[LEN], str2[LEN];
  int n, i;
  printf("Enter the string:\n");
  gets(str1);
  printf("Enter the position of the string deleted:");
  scanf(___1___);
  for (i=0; i<n; i++)
  ___2___
  str2[i] = '\0';
  printf("The new string is:%s\n", ___3___);
  }
  第1处填空:”%d”,&n
  第2处填空:str2[i]=str1[i]
  第3处填空:str2


首页 1 2 3 尾页

相关文章