更多"请编写函数fun( ),该函数的功能是:将M行N列的二维数组中的数据,"的相关试题:
[简答题]请编写函数fun,该函数的功能是:将M行N列的二维数组中的数据,按列的顺序依次存放到一维数组中。函数fun中给出的语句仅供参考。
例如,二维数组中的数据为:
33 33 33 33
44 44 44 44
55 55 55 55
则一维数组中的内容应是:
33 44 55 33 44 55 33 44 55 33 44 55
注意:部分源程序在文件PROG1.C中。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入你编写的若干语句。
文件PROG1.C内容如下:
#include<stdio.h>
void fun(int(*s)[10],int *b,int *n,int mm,int nn)
/*以下代码仅供参考*/
int i,j,np=0; /*np用作b数组的下标*/
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;
printf("The matrix: /n");
for(i=0;i<3;i++)
for(j=0;j<4;j++)printf("%3d",w[i][j]);
printf("/n");
fun(w,a,&n,3,4);
printf("The A array: /n");
for(i=0;i<n;i++)printf("%3d",a[i]);
printf("/n/n");
[简答题]请编写函数fun, 函数的功能是: 将M行N列的二维数组中的字符数据, 按列的 顺序依次放到一个字符串中。 例如, 二维数组中的数据为: W W W W S S S S H H H H 则字符串中的内容应是: WSHWSHWSH。 注意:部分源程序在文件PROG1.C中。 请勿改动主函数main和其它函数中的任何内容, 仅在函数fun的花括号中填入 你编写的若干语句。 给定源程序: #include #define M 3 #define N 4 void fun(char s[][N], char *b) { int i,j,n=0; for(i=0; i < N;i++) /* 请填写相应语句完成其功能 */ { } b[n]=’/0’; } main( ) { char a[100],w[M][N]={{’W’,’W’,’W’,’W’},{’S’,’S’,’S’,’S’},{’H’,’H’,’H’,’H’}}; int i,j; printf("The matrix:/n"); for(i=0; i
[简答题]请编写函数fun( ),函数的功能是求出二维数组周边元素之和,作为函数值返回。二维数组中的值在主函数中赋予。
例如:若二维数组中的值为
1 3 5 7 9
2 9 9 9 4
6 9 9 9 8
1 3 5 7 0
则函数值为61。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
#include<conio.h>
#include<stdio.h>
#define M 4
#define N 5
int fun( int a [M][N])
{
}
main( )
{
int aa[M][N]={{1,3,5,7,9},{2,9,9,9,4},
{6,9,9,9,8},{1,3,5,7,0}};
int i, j, y;
clrscr( );
printf ("The original data is :/n ");
for(i=0; i<N;i++)
{for (j=0; j<N;j++)
printf("%6d ",aa[i][j]);
printf("/n ");
}
y=fun(aa);
printf("/nThe sun:%d/n ",y);
printf("/n");
}
[简答题]请编写函数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";
[简答题]请编写函数fun( ),该函数的功能是:将M行N列的二维数组中的数据,按行的顺序依次放到一维数组中,一维数组中数据的个数存放在形参n所指的存储单元中。
例如,若二维数组中的数据为:
33 33 33 33
44 44 44 44
55 55 55 55
则一维数组中的内容应该是33 33 33 33 44 44 44 AA, 55 55 55 55
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
#include <stdio. h>
void fun (int (*s)[10], int *b, int *n,
int mm, int nn)
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 ;
printf ("The matrix: /n" );
for (i=0; i<3; i++)
for (j+0; j<4; j++)
printf ("%3d",w[i] [j] );
printf ("/n");
fun (w,a, &n, 3, 4);
printf ("The A array: In");
for(i=0; i<n; i++)
printf ("%3d", a [i] );
printf ("/n/n");
[简答题]请编写函数fun( ),该函数的功能是:将M行N列的二维数组中的字符数据,按列的顺序依次放到一个字符串中。
例如,若二维数组中的数据为:
W WWW
S S S S
H H H H
则字符串中的内容应是WSHWSHWSHWSH。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
#include<stdio.h>
#define M 3
#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;
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:In");
puts(a);
printf("/n/n");
}
[简答题]下列程序定义了N×N的二维数组,并在主函数中赋值。请编写一个函数fun( ),函数的功能是:求数组周边元素的平方和并作为函数值返回给主函数。例如,若数组a中的值为
0 1 2 7 9
1 11 21 5 5
2 21 6 11 1
9 7 9 10 2
5 4 1 4 1
则返回主程序后s的值应为310。
[注意] 部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
[试题源程序]
#include <stdio.h>
#include <conio.h>
#include <stdiib.h>
#define N 5
int fun(int w[][N])
main( )
int a[N][N]=0, 1, 2, 7, 9, 1, 11, 21, 5, 5, 2, 21, 6, 11, 1, 9, 7, 9, 10, 2, 5, 4, 1, 4, 1;
int i, j;
int s;
clrscr( )
printf("*****The array*****/n");
for(i=0; i<N; i++)
for(j=0; j<N; j++)
printf("%4d", a[i][j]);
printf("/n’);
s=fun(a);
printf("*****THE RESULT*****/n");
printf("The sum is: %d/n", s);
[简答题]下列程序定义了NXN的二维数组,并在主函数中赋值。请编写函数fun( ),函数的功能是求出数组周边元素的平方和并作为函数值返回给主函数中的s。例如:若a数组中的值为
a=0 1 2 7 9
1 11 21 5 5
2 21 6 11 1
9 7 9 10 2
5 4 1 4 1
则返回主程序后s的值应为310。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
#include <stdio.h>
#include<conio.h>
#include<stdlib.h>
#define N 5
int fun (int w[][N])
main( )
int a[N][N]=0,1,2,7,9,1,11,21,5,5,2, 21,6,11,1,9,7,9,10,2,5,4,1,4,1;
int i,j;
int s;
clrscr( );
printf("*****The array***+*/n");
for (i=0;i<N;i++)
for(j=0;j<N;i++)
printf("%4d",a[i][j]);
printf("/n");
s=fun(a);
printf("*****THE RESULT*****/n");
printf("The sum is:%d/n",s);
[简答题]编程题下列程序定义了N×N的二维数组,并在主函数中赋值。请编写函数fun( ),函数的功能是:求出数组周边元素的平方和并作为函数值返回给主函数中的s。例如:若a 数组中的值为a=0 1 2 7 91 11 21 5 52 21 6 11 19 7 9 10 25 4 1 4 1则返回主程序后s的值应为310。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。试题程序:#include #include#include#define N 5int fun (int w[][N]){}main( ){ int a[N][N]={0,1,2,7,9,1,11,21,5,5,2,21,6,11,1,9,7,9,10,2,5,4,1,4,1}; int i, j; int s; clrscr( ); printf("*****The array*****/n "); for (i=0; i
[多项选择]编程题
下列程序定义了N×N的二维数组,并在主函数中赋值。请编写函数fun( ),函数的功能是:求出数组周边元素的平方和并作为函数值返回给主函数中的s。例如:若a 数组中的值为
a=0 1 2 7 9
1 11 21 5 5
2 21 6 11 1
9 7 9 10 2
5 4 1 4 1
则返回主程序后s的值应为310。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
#include
#include
#include
#define N 5
int fun (int w[][N])
{
}
main( )
{
int a[N][N]={0,1,2,7,9,1,11,21,5,5,2,21,6,11,1,9,7,9,10,2,5,4,1,4,1};
int i, j;
int s;
clrscr( );
printf("*****The array*****/n ");
for (i=0; i
[简答题]请编写函数fun,其功能是:找出2xM整型二维数组中最大元素的值,并将此值返回调用函数。
注意:部分源程序给出如下。
请勿改动主函数mam和其他函数中的任何内容,仅在函数fun的花括号中填入你编写的若干语句。
试题程序:
#define M 4
#include <stdio.h>
int fun (int a[][M])
void main ( )
int arr[2][M]=5, 8, 3, 45, 76,
4, 12, 82;
printf("max=% d/n", fun(arr));
[简答题]请编写函数fun,其功能是:找出2×M整型二维数组中最大元素的值,并将此值返回调用函数。 注意:部分源程序给出如下。 请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入你编写的若干语句。 试题程序: #define M 4 #include <stdio.h> int fun(int a[][M]) { } void main( ) { int arr[2][M]={5, 8, 3, 45, 76, -4, 12, 82}; printf(”max=% d/n", fun(arr)); }
[简答题]请编写一个函数fun( ),它的功能是:求出一个4×M整型二维数组中最小元素的值,并将此值返回调用函数。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仪在函数fun的花括号中填入所编写的若干语句。
试题程序:
#define M 4
#include <stdio.h>
fun (int a[])[M])
{
}
main( )
{
int arr[4][M]={11,3,9,35,42,-4,24,32,6,48,-32,7,23,34,12,-7);
printf("min=%d/n",fun(arr));
}