以下函数的功能是:计算a的n次方作为函数值返回。 double fun(double a,int n) { int i;double s=1.0; for(i=1;i A.s*iB.s*aC.s+i*iD.s+a*a

以下函数的功能是:计算a的n次方作为函数值返回。 double fun(double a,int n) { int i;double s=1.0; for(i=1;i<=n;i++)s= ; return s; } 为实现上述功能,函数中下划线处应填入的是( )。

A.s*i

B.s*a

C.s+i*i

D.s+a*a


相关考题:

若有以下函数首部int fun(double x[10], int *n)则下面针对此函数的函数声明语句中正确的是A)int fun(double x, int *n);B)int fun(double , int );C)int fun(double *x, int n);D)int fun(double *, int *);

函数 void fun(float *sn, int n)的功能是:根据以下公式计算S,计算结果通过形参指针sn传回;n通过形参传入,n的值大于等于0。请填空。void fun( float *sn, int n){ float s=0.0, w, f=-1.0;int i=0;for(i=0; i=n; i++){ f=( )* f;w=f/(2*i+1);s+=w; }( )=s;}

函数int factors(int n)的功能是判断整数n(n>=2)是否为完全数。如果n是完全数,则函数返回0,否则返回-1。所谓“完全数”是指整数n的所有因子(不包括n)之和等于n自身。例如,28的因子为1,2,4,7,14,而28=1+2+4+7+14,因此28是“完全数”。[C函数1]int factors(int n){ int i,s;for(i=1,s=0;i<=n/2;i++)if(n%i=0) (1)______;if( (2)______ )return 0;rerurn-1;}[说明2]函数int maxint(int a[],int k)的功能是用递归方法求指定数组中前k个元素的最大值,并作为函数值返回。[C函数2]int maxint(int a[],int k){ int t;if( (3)_____ ) return (4)_______;t=maxint(a+1, (5)______ );return(a[0]>t)?a[0]:t;}

请补充函数fun(),该函数的功能是求一维数组x[N]的平均值,并对所得结果进行四舍五入(保留两位小数)。例如:当x[10]={15.6, 19.9, 16.7, 15.2, 18.3, 12.1, 15.5,11.0, 10.0, 16.0},结果为:avg=15.030000。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仪在函数fun的横线上填入所编写的若干表达式或语句。试题程序:include<stdio.h>include<conio.h>double fun(double x[10]){int i;long t;double avg=0.0;double sum=0.0;for(i=0;i<l0;i++)【 】;avg=sum/10;avg=【 】;t=【 】;avg=(double)t/100;return avg;}main(){double avg,x[10]={15.6,19.9,16.7,15.2,18.3,12.1,15.5,11.0,10.0,16.0};int i;clrscr();printf(“\nThe original data is:\n”);for(i=0;i<l0;i++)printf("%6.lf",x[i]);printf(“\n\n”);avg=fun(x);printf(“average=%f\n\n”,avg);}

函数fun的功能是:根据以下公式求p的值,结果由函数值返回。m与n为两个正数且要求mn。例如:m=12,n=8时,运行结果应该是495.000000。请在题目的空白处填写适当的程序语句,将该程序补充完整。#include#includefloat fun (int m, int n){ int i;double p=1.0;for(i=1;i=m;i++)( );for(i=1;i=n;i++)( );for(i=1;i=m-n;i++)p=p/i;return p;}main (){ clrscr();printf ("p=%f\n",fun (12,8));}

学生的记录由学号和成绩组成,N名学生的数据已在主函数中放入结构体数组s中,请编写函数fjun(),该函数的功能是:把高于等于平均分的学生数据放在b所指的数组中,高于等于平均分的学生人数通过形参n传回,平均分通过函数值返回。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。试题程序:include <stdio.h>define N 12typede f struct{ char num[10];double s;} STREC;double fun (STREC *a,STREC *b, int *n){}main ( )STREC s IN] = { { "GA05", 85 }, { "GA03", 76 },{"GA02", 69}, {"GA04", 85}, {"GA01", 91},{"GA07", 72}, {"GA08", 64}, {"GA06", 87},{"GA09", 60}, { "GAll", 79 }, { "GA12", 73},{"GA10", 90 } };STREC h[N],t;FILE *out;int i ,j,n;double ave;ave=fun (s, h, n);printf("The %d student data which ishigher than %7.3f: In", n, ave);for(i=0; i<n; i++)printf ("%s %4.1f\n",h[i] .num, h[i] .s);printf ("\n");out=fopen ("out90.dat", "w");fprintf(out, "%dkn %7.3f\n",n,ave);for(i=0; i<n-1; i++)for (j=i+l; j<n; j ++)if (h[i] .s<h[j ] .s){t=h Ii] ;h[i]=h[j] ;h[j]=t; }/*分数从高到低排列*/for(i=0; i<n; i++)fprintf(out, "%4.1f\n",h[i] .s);fclose (out);}

请补充函数fun(),该函数的功能是:计算N×N维矩阵元素的方差,结果由函数返回。维数N在主函数中输入。例如:注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。试题程序:include <stdio.h>include <conio.h>include <stdlib.h>include <math.h>define N 20double fun(【 】,int n){int i,j;int k;double s=0.0;double f=0.0;double aver=0.0;double sd=0.0;for(i=0;i<n;i++)for(j=0;j<n;j++)s+=a[i][j];aver=【 】;for(i=0;i<n;i++)for(j=0;i<n;j++)f+=(a[i][j]-aver)*(a[i][j]-aver);f/(n*n);sd=【 】;return sd;}main(){int a[N][N];int n;int i,j;double s;clrscr();printf("***+Input the dimension ofarray N*****\n");scanf("%d",n);printf("***** The array *****\n");for(i=0;i<n;i++){for(j=0;j<n;j++){a[i][j]=rand()%50;while(a[i][j]=0)a[i][j]=rand()%60;printf("%4d",a[i][j]);}printf("\n\n");}s=fun(a,n);printf("******* THE RESULT *******\n");printf("%4.3f\n",s);}

请补充函数fun,其功能是:计算并输出给定10个数的方差:例如,给定的10个数为15.0,19.0,16.0,15.0,18.0,12.0, 15.0,11.0,10.0,16.0,输出为s=2.758623。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。试题程序:include<stdio.h>include<math. h>double fun (double x[10]){int i;double avg=0.0;double sum=0.0;double abs=0.0;double sd;for (i=0; i<10; i++)【 】;avg=sum/10;for(i=0;i<10;i++)【 】;sd=【 】;return sd;}main(){double s,x[10]={15.0,19.0,16.0,15.0,18.0,12.0,15.0,11.0,10.0,16.0};int i;printf("\nThe original data is :\n");for(i=0;i<10;i++)printf("%6.1f",x[i]);printf("\n\n");s=fun(x);printf("s=%f\n\n",s);}

以下fun函数的功能是:找出具有N个元素的一维数组中的最小值,并作为函数值返回,请填空。(设N己定义)int fun(int x[N]){int i,k=0for(i=0;iN;i++)if(x[i]x[k])k=_____;return x[k];}

下列程序定义了N×N的二维数组,并在主函数中赋值。请编写函数fun(),函数的功能是:求出数组周边元素的平均值并作为函数值返回给主函数中的s。例如:若a数组中的值为a= 0 1 2 7 91 9 7 4 52 3 8 3 14 5 6 8 25 9 1 4 1则返回土程序后s的值应为3.375。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的仟何内容,仅在函数fun的花括号中填入所编写的若干语句。试题程序:include <stdio.h>include<conio.h>include<stdlib.h>define N 5double 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名学生的数据已存放在主函数的结构体数组s中,请编写函数fun,它的功能是:把低于平均分的学生数据放在b所指的数组中,低于平均分的学生人数通过形参n传回,平均分通过函数值返回。[注意] 部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在fun函数的花括号中填入所编写的若干语句。[试题源程序]include<stdio.h>define N 8typedef struct{char num[10];double s;}STREC;double fun(STREC *a, STREC *b, int *n){}void main(){STREC s[N]={{"GA05", 85},{"GA03", 76}, {"GA02", 69}, {"GA04", 85},{"GA01", 91}, {"GA07", 72}, {"GA08", 64},{"GA06", 87}};STREC h[N], t; FILE *out;int i, j, n;double ave;ave=fun(s, h, &n);printf("The %d student data which is lower than %7.3 f:\n", n, ave);for(i=0; i<n; i++)printf("%s %4.1f\n", h[i]. num, h[i].s);printf("\n");ut=fopen("out.dat", "W");fprintf(out, "%d\n%7.3f\n", n, ave);for(i=0; 2<n-1; i++)for(j=i+1; j<n; j++)if(h[i]. s>h[j].s){t=h[i];h[i]=h[j];h[j]=t;}for(i=0; 2<n; i++)fprintf(out, "%4.1f\n", h[i].s);fclose(out);}

阅读以下说明和C语言函数,将应填入(n)处的字句写在对应栏内。[说明]编写一个函数,输入为偶数时,调用函数求1/2+?/+…+1/n,当输入n为奇数时,调用函数1/1+1/3+…+1/n (利用指针函数)。[函数]include "stdio. h",main(){float peven (),podd (),dcall ();float sum;int n;while (1){scanf("%d",n);if (n>1)break;}if(n%2==0){printf("Even="):(1);}else{pfinff("Odd=");(2);}printf("%f",sum);}float peven (int n){float s;int is=1;for(i=2;i<=n;i+=2)(3);return (s);}float podd (n)int n;{float s;int i;s=0;for(i=1 i<=n;i+=2)(4);return (s);}float dcall(fp,n)float (*fp) ();int n;{float s;(5);returu (s);}

设在主函数中有以下定义和函数调用语句,且fun()函数为void类型,请写出fun()函数的首部______。int main(){double s[10][22];int n:...fun (s):...return 0;}

若有以下函数首部: int fun(double x[10],int *n) 则下面针对此函数的函数声明语句中正确的是( )。A.int fun(double x, int *n);B.int fun(double, int);C.int fun(double *x, int n);D.int fun(double*, int*);

阅读下列函数说明和C代码,将应填入 处的字句写在答题纸的对应栏内。[函数1.1说明]函数int factors(int n)的功能是判断整数n(n=2)是否为完全数。如果n是完全数,则函数返回0,否则返回-1。所谓“完全数”是指整数n的所有因子(不包括n)之和等于n自身。例如28的因子为1、2、4、7、14,而28=1+2+4+7+14,因此28是“完全数”。[函数1.1]int factors(int n){int i,s;for(i=1,s=0;i=n/2;i++)if(n%i==0) (1) ;if( (2) )return 0;return -1;}[函数1.2说明]函数int maxint(int a[], int k)的功能是用递归方法求指定数组中前k个元素的最大值,并作为函数值返回。[函数1.2]int maxint(int a[],int k){int t;if( (3) ) return (4) ;t=maxint(a+1, (5) );return (a[0]t)?a[0]:t;

以下函数的功能是:求x的y次方,请填空。double fun(double x,int y){ int i; double z; for(i=1,z=x;iy;i++) z=z*; return z;}

若有以下函数首部 int fun(double x[lO],int *n) 则下面针对此函数的函数声明语句中正确的是______。A.int fun(double x, int *n);B.int fun(double, int);C.int fun(double *x, int n);D.iht fun(double*,int*);

请编写函数fun(),其功能是:计算并输出给定10个数的方差。其中例如,给定的10个数为95.0,89.0,76.0,65.0,88.0, 72.0,85.0,81.0,90.0,56.0,则输出为S=11.730729。注意;部分源程序给出如下.请勿改动主函数mam和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。试题程序:include<math.h>include<stdio.h>double fun(double x[10]){}main(){double s,x[i0]={95.0,89.0,76.0,65.0,88.0,72.0,85.0,81.0,90.0,56.0};int i;printf("\nThe original data is:\n");for(i=0;i<10;i++)printf("%6.1f ",x[i]);printf("\n\n ");s=fun(x);printf("s=%f\n\n ",s);}

请编写函数fun(),它的功能是计算:s=(1-In(1)-In(2)-In(3)-…-1n(m))2s作为函数值返回。在C语言中可调用log(n)函数求In(n)。log函数的引用说明是double log(double x)。例如,若m的值为15,则fun()函数值为723.570801。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。试题程序:include <conio.h>include <stdio.h>include <math.h>double fun(int m){}main(){clrscr();printf("%f\n",fun(15));}

以下sum函数的功能是计算下列级数之和:请给函数中的各变量正确赋初值。double sum(douLle x,int n){ int i;double a,b,s;【 】for(i=1;i<=n;i++) {a=a*x;b=b*i;s=s+a/b;}return s;}

下列给定程序中,函数fun()的功能是:计算S=f(-n)+f(-n+1)+…+f(0)+f(1)+f(2)+…f(n)的值。例如,当n为5时,函数值应为10.407143。f(x)函数定义如下:请改正程序中的错误,使它能得山正确的结果。注意:不要改动main 函数,不得增行或删行,也不得更改程序的结构。试题程序:include <conio. h>include <stdio. h>include <math. h>/**************found***************/f (double x){if (x==0.0 || x==2.0)return 0.0;else if (x<0.0)return (x-1) / (x-2);elsereturn (x+1) / (x-2);}double fun(int n){int i; double s=0.0,y;for (i=-n; i<=n; i++){ y=f(1.0*i); s+=y;}/**************found**************/return s}main(){ clrscr();printf ("%f\n", fun (5));}

请编写函数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(),该函数的功能是计算下面公式SN的值:例如:当N=50时,SN=71.433699。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。试题程序:include<conio.h>include<stdio.h>double fun(int n){double s=1.0,S1=0.0;int k;for(【l】;k<=n;k++){s1=s;【 】;}return【 】;}main(){int k=0;double S;clrscr();printf("\nPlease input N=");scanf("%d",k);s=fun(k);printf("\ns=%lf",s);}

请补充函数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);}

阅读以下说明和C函数,填补函数代码中的空缺,将解答填入答题纸的对应栏内。[说明1]函数f(double eps)的功能是:利用公式计算并返回π的近似值。[C函数1] double f(doubleeps) { double n=1.0, s=1.0, term=1.0, pi=0.0; while ( fabs(term) >=eps ){ pi=pi+term; n= ______; s= ______; term=s/n; } return pi*4; }[说明2]函数fun(char *str)的功能是:自左至右顺序取出非空字符串str中的数字字符,形成一个十进制整数(最多8位)。例如,若str中的字符串为"iyt?67kp f3g8d5.j4ia2e3p12",则函数返回值为67385423。[C函数2] long fun(char*str) { int i=0; long num: 0; char *p = str; while ( i<8 ++i; } ______; } return num; }

单选题若有以下函数首部int fun(double x[10],int*n)则下面针对此函数的函数声明语句中正确的是(  )。Aint fun(double*,int*);Bint fun(double,int);Cint fun(double *x,int n);Dint fun(double x,int*n);

单选题以下函数的功能是计算a的n次方作为函数值返回:doublefun(doublea,intn){ inti; doubles=1.0; for(i=1;i=n;i++)s=______; returns;}为实现上述功能,函数中下画线处应填入的是(  )。As*iBs*aCs+i*iDs+a*a