首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 计算机考试 > 等级考试 > 二级考试 >

计算机二级C语言上机题考前预测(附答案)(2)(1)

2013-03-26 
计算机二级C语言上机题考前预测(附答案)(2)

  填空题

  请补充fun函数,该函数的功能是:先将在字符串s中的字符按逆序存放到t串中,然后把s中的字符按正序连接到t串的后面。

  例如:s中的字符串为ABCDE时,则t中的字符串应为EDCBAABCDE。

  请勿改动主函数main和其他函数中的任何内容,仅在fun函数的横线上填入所编写的若干表达式或语句。

  #include

  #include

  #include

  void fun(char *s, char *t)

  {

  int s1, i;

  s1 = strlen(s);

  for (i=0; i

  t[i] = s[___1___];

  for (i=0; 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


热点排行