2013年计算机二级C语言上机题库四十一_第3页

考试站(www.examzz.com)   【考试站:中国教育考试第一门户】   2013年6月3日
  第三题:编程题
  请编写函数fun,该函数的功能是;将M行N列的二维数组中的字符数据,按列的顺序依次放到一个字符串中。
  例如,若二维数组中的数据为:
  W W W W
  S S S S
  H H H H
  则字符串中的内容应是WSHWSHWSH。
  请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
  #include <stdio.h>来自www.examzz.com
  #define M 3 http://ks.examda.com
  #define N 4
  void fun(char (*s)[N], char *b)
  {
  }
  main()
  {
  char a[100],w[M][N]={{'w','w', 'w','w'},{'S','S','S','S'},{'H','H','H','H'}};
  int i,j;
  FILE *out;
  printf("The matrix:\n");
  for(i=0; i<M; i++)
  {
  for(j=0;j<N; j++)
  printf("%3c",w[i][j]);
  printf("\n");
  }
  fun(w,a);
  printf("The A string:\n");
  puts(a);
  printf("\n\n");
  out=fopen ("out.dat", "w");
  fprintf(out, "%s", a);
  fclose (out );
  }
首页 1 2 3 尾页

相关文章