问答题

请编写函数fun(),该函数的功能是将M行N列的二维数组中的数据,按列的顺序依次放到一维数组中。 例如:二维数组中的数据为 33333333 44444444 55555555 则一维数组中的内容应是 334455334455334455334455。 注意:部分源程序以存在文件test_2.cpp中。 请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。 文件test39_2.cpp的内容如下: #include<stdio.h> #include<iostream.h> void fun(int(*s) [10],int *b, int *n,int mm,int nn) { } void main( ) { int w[10][10]={{33,33,33,33},{44,44,44,44},{55,55,55,55}},i,j; int a[100]={0}, n=0; cout<<"The matrix:\n" for(i=0; i<3; i++) { for(j=0; j<4; j++ cout<<w[i] [j]; cout<<endl; } fun(w, a, &n, 3, 4); cout<<"The A array:\n"; for(i=0; i<n; i++) cout<<a[i]; cout<<"\n\n"; }

【参考答案】

void fun (int(*s)[10],int *b, int *n, int mm, int nn) { int ......

(↓↓↓ 点击下方‘点击查看答案’看完整答案 ↓↓↓)