2013年计算机二级C语言上机试题六十四及答案

2014-11-23 19:20:08 · 作者: · 浏览: 13

  填空题
  请补充main函数,该函数的功能是:把字符串str1中的非空格字符拷贝到字符串str2中.
  例如,若str1=”nice to meet you!”,则str2=”nicetomeetyou!”
  仅在横线上填入所编写的若干表达式或语句,勿改动函数中的其他任何内容.
  #include
  #define N 80
  main()
  {
  static char str1[N] = "nice to meet you!";
  char str2[N];
  int i = 0, j = 0;
  printf("\n****** str1 ******\n ");
  puts(str1);
  while (str1[i])

  {
  if (___1___)
  str2[j++] = str1[i];
  ___2___;
  }
  printf("\n****** str2 ******\n ");
  for (i=0; i   printf("%c", str2[i]);
  }
   参考答案:
  第一题:
  第1处填空str1[i]!=’ ’或’ ’!= str1[i]
  第2处填空i++或++i或i+=1或i=i+1