更多"下列程序定义了M×M的二维数组,并在主函数中赋值。请编写函数proc("的相关试题:
[简答题]下列程序定义了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 9
1 9 7 4 5
2 3 8 3 1
4 5 6 8 2
5 9 1 4 1
则返回土程序后s的值应为3.375。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的仟何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
#include <stdio.h>
#include<conio.h>
#include<stdlib.h>
#define N 5
double fun (int w[] [N])
{
}
main( )
{
int a[N] [N]={0,1,2,7,9,1,9,7,4,5,2,
3,8,3,1,4,5,6,8,2,5,9,1,4,1};
int i, j;
double 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 : %lf/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
[简答题]下列程序定义了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<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;j++)
printf("%4d",a[i][j]);
printf("/n");
S=fun(a):
printf("*****THE RESULT*****/n");
printf("The sum is:%d/n",s);
[简答题]请编写函数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");
}
[简答题]请编写函数proc( ),函数的功能是求出二维数组周边元素之和,作为函数值返回。二维数组中的值在主函数中赋予。
例如,若二维数组中的值为:
0 1 2 3 4
5 9 7 4 5
4 3 8 3 6
3 5 6 8 7
则函数值为59。
注意:部分源程序已给出。
请勿改动主函数main和其他函数中的任何内容,仅在函数proc的花括号中填入所编写的若干语句。
试题程序:
#include<stdlib.h>
#include<conio.h>
#include<stdio.h>
#define M 4
#define N 5
int proc(int a[M][N])
void main( )
int aa[M]EN]=0, 1, 2, 3, 4, 5, 9, 7.4, 5,
4, 3, 8, 3, 6, (3, 5, 6.8, 7;
int i, j, y;
system("CLS");
printf("The original data is: /n");
for(i=0; i<M; i++)
for(j=0; j<N; j++)
printf("%6d", aa[i][j]);
printf("/n");
y=proc(aa);
printf("/nThc sun: %d/n", y);
printf("/n");
[多项选择]编程题
程序定义了N×N的二维数组,并在主函数中自动赋值。请编写函数fun(int a[ ][ N ],int n),该函数的功能是使数组左下半三角元素中的值加上n。
例如:若n的值为3,a数组中的值为
a=2 5 4
1 6 9
5 3 7
则返回主程序后a数组中的值应为
5 5 4
4 9 9
8 6 10
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
#include
#include
#include
#define N 5
fun(int a[ ][N], int n)
{
}
main( )
{
int a[N][N],n, i,j;
clrscr( );
printf("***** The array *****/n");
for(i=0; i=5);
printf("n=%4d/n",n);
fun(a, n);
printf("*****THE RESULT*****/n");
for(i=0; i
[简答题]下列程序定义了NXN的二维数组,并在主函数中自动赋值。请编写函数fun(int a[][N]),该函数的功能是使数组右上半三角元素中的值全部置成0。例如a数组中的值为
a=4 5 6
1 7 9
3 2 6,
则返回主程序后a数组中的值应为
0 0 0
1 0 0
3 2 0
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
#include<conio.h>
#include<stdio.h>
#include<stdlib.h>
#define N 5
int fun(int a[ ][N])
{
}
main( )
{
int a[N][N],i,j;
clrscr( );
printf("*****The array*****/n");
for(i=0;i<N;i++)
/*产生—个随机的5*5矩阵*/
{ for(j=0;j<N;j++)
{a[i][j]=rand( )%10;
printf ("%4d",a[i][j]);
}
printf("/n");
}
fun(a);
printf("THE RESULT/n");
for(i=0;i<N;i++)
{ for(j=0;i<N;j++)
printf("%4d",a[i][j]);
printf("/n");
}
}
[多项选择]编程题
下列程序定义了N×N的二维数组,并在主函数中自动赋值。请编写函数fun(int a[][N]),该函数的功能是:使数组右上半三角元素中的值全部置成0。例如a数组中的值为
a=4 5 6
1 7 9
3 2 6,
则返回主程序后a数组中的值应为
0 0 0
1 0 0
3 2 0
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
#include
#include
#include
#define N 5
int fun (int a[][N])
{
}
main( )
{
int a[N][N],i,j;
clrscr( );
printf("*****The array*****/n");
for(i=0;i
[简答题]程序定义了N×N的二维数组,并在主函数中自动赋值。
请编写函数fun(int a[][N],int n),该函数的功能是使数组左下半三角元素中的值加上n。
例如:若n的值为3,a数组中的值为
a=2 5 4
1 6 9
5 3 7
则返回主程序后a数组中的值应为
5 5 4
4 9 9
8 6 10
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数full的花括号中填入所编写的若干语句。
试题程序:
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#define N 5
fun(int a[][N],int n)
{
}
main( )
{
int a[N][N],n,i,j;
clrscr( );
printf("***** The array *****/n");
for(i=0;i<N;i++)
/*产生—个随机5*5矩阵*/
{
for(j=0;j<N;j++)
{
a[i][j]=rand( )%10;
printf("%4d",a[i][j]);
}
printf("/n");
}
do
n=rand( )%10;
/*产生一个小于5的随机数n*/
while(n>=5);
printf("n=%4d/n",n);
fun(a,n);
printf("*****THE RESULT*****/n");
for(i=0;i<N;i++)
{
for(j=0;j<N;i++)
printf("%4d",a[i][j]);
printf("/n");
}
}
[简答题]程序定义了N×N的二维数组,并在主函数中自动赋值。
请编写函数fun(int a[][N],int n),该函数的功能是使数组左下半三角元素中的值加上n。
例如:若n的值为3,a数组中的值为
a=2 5 4
1 6 9
5 3 7
则返回主程序后a数组中的值应为
5 5 4
4 9 9
8 6 10
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数full的花括号中填入所编写的若干语句。
试题程序:
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#define N 5
fun(int a[][N],int n)
main( )
int a[N][N],n,i,j;
clrscr( );
printf("***** The array *****/n");
for(i=0;i<N;i++)
/*产生—个随机5*5矩阵*/
for(j=0;j<N;j++)
a[i][j]=rand( )%10;
printf("%4d",a[i][j]);
printf("/n");
do
n=rand( )%10;
/*产生一个小于5的随机数n*/
while(n>=5);
printf("n=%4d/n",n);
fun(a,n);
printf("*****THE RESULT*****/n");
for(i=0;i<N;i++)
for(j=0;j<N;i++)
printf("%4d",a[i][j]);
printf("/n");
[简答题]下列程序定义了N×N的二维数组,并在主函数中自动赋值。请编写函数fun(int a[][N],int n),该函数的功能是:使数字右上半三角元素中的值乘以m。
例如,若m的值为2,a数组中的值为
a=1 9
2 7
则返回主程序后a数组的值应为
2 18
2 14
注意:部分源程序给出如下.
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
#include<conio.h>
#include<stdio.h>
#include<stdlib.h>
#define N 5
int fun(int a[] [N], int m)
main( )
int a[N] [N],m, i, j;
clrscr ( );
printf "*****The array*****/n");
for (i=O; i<N; i++)
/*输出一个随机的5×5矩阵*/
for(j=0; j<N; j++)
a[i] [j]=rand( )%20;
printf("%4d", a[i] [j]);
printf ("/n");
do
m=rand ( ) %10;
while (m>=3); /*产生一个上于3的随机数*/
printf ("m=%4d/n", m);
fun (a,m);
printf ("THE RESULT/n");
for (i=0; i<N; i++)
for(j=0;j<N;j++)
printf ("%4d",a[i] [j]);
printf ("/n");