2013年计算机二级C语言上机题库四十五

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

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

 填空题
  请补充fun函数,该函数的功能是:先将在字符串s中的字符按逆序存放到t串中,然后把s中的字符按正序连接到t串的后面。
  例如:s中的字符串为ABCDE时,则t中的字符串应为EDCBAABCDE。
  请勿改动主函数main和其他函数中的任何内容,仅在fun函数的横线上填入所编写的若干表达式或语句。
  #include <conio.h>
  #include <stdio.h>
  #include <string.h>
  void fun(char *s, char *t)
  {
  int s1, i;
  s1 = strlen(s);
  for (i=0; i<s1; i++)
  t[i] = s[___1___];
  for (i=0; i<s1; i++)
  t[s1+i] = s[i];
  t[___2___] = '\0';
  }
  main()
  {
  char s[100], t[100];
  printf("\nPlease enter string s:");
  scanf("%s", s);
  fun(s, t);
  printf("The result is: %s\n", t);
  }
  参考答案:1:s1-i-1或s1-1-i
  2:2*s1或s1*2


首页 1 2 3 尾页

相关文章