请补充函数fun(),该函数的功能是:输出一个N×N矩阵,N由键盘输入,矩阵元素的值为随机数,并计算出该矩阵四周边元素的平均值,结果由函数返回。例如:当N=4时:注章:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun的横线上填入所编写的若干表达式或语句。试题程序;include<stdio.h>include<conio.h>include<stdlib.h>define N 20double fun(int a[ ][N],int n){int i,j;int k;double s=0.0;double aver=0.0;printf("*****The array*****\n");for(i=0;i<n;i++){for(j=0;j<n;j++){a[i][j]=rand()%10;printf("%4d",a[i][j]);if(【 】)s+=a[i][j];}printf("\n");}k=【 】;aver=【 】;return aver;}main( ){int a[N][N];int n;double S;Clrscr( );printf("*****Input the dimension Of array N*****\n");scanf(“%d”,n);S=fun(a,n);printf(“***** THE RESULT *****\n”);printf(“The average is %2,3f\n”,S);}

请补充函数fun(),该函数的功能是:输出一个N×N矩阵,N由键盘输入,矩阵元素的值为随机数,并计算出该矩阵四周边元素的平均值,结果由函数返回。例如:当N=4时:

注章:部分源程序给出如下。

请勿改动主函数main和其他函数中的任何内容,仅在函数fun的横线上填入所编写的若干表达式或语句。

试题程序;

include<stdio.h>

include<conio.h>

include<stdlib.h>

define N 20

double fun(int a[ ][N],int n)

{

int i,j;

int k;

double s=0.0;

double aver=0.0;

printf("*****The array*****\n");

for(i=0;i<n;i++)

{

for(j=0;j<n;j++)

{

a[i][j]=rand()%10;

printf("%4d",a[i][j]);

if(【 】)

s+=a[i][j];

}

printf("\n");

}

k=【 】;

aver=【 】;

return aver;

}

main( )

{

int a[N][N];

int n;

double S;

Clrscr( );

printf("*****Input the dimension Of array N*****\n");

scanf(“%d”,&n);

S=fun(a,n);

printf(“***** THE RESULT *****\n”);

printf(“The average is %2,3f\n”,S);

}


相关考题:

请补充main函数,该函数的功能是:输出一个NXN矩阵,要求非周边元素赋值0,周边元素赋值1。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在 main函数的横线上填入所编写的若干表达式或语句。试题程序:include<stdio .h>define N 10main(){int bb[N] IN];iht i,j,n;clrscr 0;printf (" \nInput n: \n");scanf ("%d", n);for (i=0; i<n; i++ )for (j=0; j<n; j++){if(【 】)bb[i] [j]=l;else【 】;}printf(" \n*** the result *** \n");for (i=0; i<n; i++){printf (" \n\n");for (j=0; j<n; j++)printf ("%4d",bb [i] [j ] );}}

编写函数fun(),它的功能是;根据以下公式求p的值,结果由函数值带回。m与n为两个正数且要求m>n。P=m!/n!(m-n)!),例如:m=12,n=8时,运行结果为495.000000。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。试题程序:include <conio.h>include <stdio.h>float fun (int m, int n){}main(){clrscr() ;printf ("p=%f\n", fun (12,8) ) ;}

请补充main函数,该函数的功能是:从键盘输入一个长整数,如果这个数是负数,则取它的绝对值,并显示出来。例如,输入:-3847652,结果为:3847652。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。试题程序:include<stdio.h>include<conio.h>main(){long int n;clrscr();printf("Enter the data;\n");scanf(【 】);printf("*** the absolute value ***\n");if(n<0)【 】printf("\n\n");printf(【 】);}

请编写函数fun(),它的功能是计算下列级数和,和值由函数值返回。S=1+x+x2/2!3/3!+…/xn/n!例如,当n=10,x=0.3时,函数值为1349859。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun 的花括号中填入所编写的若干语句。试题程序:include<conio.h>include<stdio.h>include<math.h>double fun(double x, int n){}main (){clrscr ();printf ("%f ",fun(0,3,10));}

请编写函数fun(),其功能是:计算并输出下列多项式的值。S=1+4/(1+2)+1/(1+2+3)+…+1/(1+2+3+…+n)例如,着主函数从键盘给n输入50后,则输出为 S=1.960784。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。试题程序:include <stdio.h>double fun(int n){}main (){int n;double s;printf ("\nInput n: ");scanf ("%d", n);s=fun (n);printf ("\n\ns=%f\n\n", s);}

请编写一个函数fun(),它的功能是计算并输出给定整数n的所有因子(不包括1与自身)的平方和(规定n的值不大于100)。例如:主函数从键盘给输入n的值为56,则输出为 sum=1113。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。试题程序:include <stdio.h>long fun(int n){}main(){int n;long sum;printf("Input n:");scanf("%d",n);sum=fun(n);printf("sum=%ld\n",sum);}

请编写函数fun(),该函数的功能是:计算并输出S=1+(1+20.5)+(1+20.5+30.5)+…+(1+20.5+30.5+…+n0.5)例如,若主函数从键盘给n输入20后,则输出为s=534.188884。注意;部分源程序给出如下。请勿改动主函数main 和其他函数中的任何内容,仅在函数fun 的花括号中填入所编写的若干语句。试题程序:include <math. h>include <stdio. h>double fun(int n){}main(){int n;double s;printf("\n\nInput n: ");scanf ("%d", n);s=fun (n)printf ("\n\ns=%f\n\n", s);}

编写函数fun(),其功能是计算:s作为函数值返回。在C语言中可调用log(n)函数求1n(n)。log函数的引用说明为:double log(double x)。例如,若m的值为20,则fun()函数值为6.506583。注意:部分源程序给出如下。请勿改动main()函数和其他函数中的任何内容,仅在函数fun()的花括号中填入你编写的若干语句。试题程序:

请编写程序fun,函数的功能是:实现B=A+Aˊ,即把矩阵A加上A的转置,存放在矩阵B中。计算结果在main函数中输出。例如,输入下面的矩阵: 其转置矩阵为:1 2 3 1 4 74 5 6 2 5 87 8 9 3 6 9程序输出:2 6 106 10 1410 14 18注意:部分源程序在文件PROGl.C中。请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入你编写的若干语句。