闽高校计算机等级考试题目
第一题:打开程序,完成其中的fun()函数,使其计算:1 x<=0
fun(x)=2.6+|x| x>0
3+sin(x)
注:(1)修改程序在每对“/**/”之间存在的错误;
(2)不得删改程序中的“/**/”注释和其它代码;
程序代码:#include <stdio.h>
#include <math.h>
double fun(float x)
{
/**/
/**/
}
void main()
{
float x;
double y;
printf("Please input a number: \n");
scanf("%f",&x);
y = fun(x);
printf("fun(%.3f)=%.3f\n",x,y);
getch();
}第二题,完成其中的f(double k,int n )函数,该函数根据形参x、n,按如下公式计算前n项并返回计算结果:k k + k k + k .... k
f(k,n)= 1*2 2*3 3*4 4*5 5*6 n(n+1)
程序代码:#include <stdio.h>
double f(double k,int n)
{ double t=0;
/**/
/**/
return (t);
}
void main()
{ double sum;
sum=f(5.36,9);
printf("f(5.36,9)= %.3lf\n ",sum);
getch();
}
第三题 填空题 将程序填写完整,其中的aver()函数计算数组num[]中的所有元素的平均值。
程序代码:#include <stdio.h>
void main()
{
int num[6]={49,33,38,26,62,23};
float ans;
/**/ /**/
ans=aver(num, 6);
printf("Average=%.2f\n",ans);
getch();
}
float aver(int x[] ,int n)
{
int k;
float sum,avg;
sum=0.0;
for(k=0;k<n;k++)
sum=/**/ /**/;
avg=sum/n;
return(avg);第四题 将程序填写完整,该程序将输入的m按实数除以n,输出他们的商以及商的第三位小数。
程序代码:#include<stdio.h>
void main()
{
int m,n,k;
float ans;
clrscr();
printf("Please input m n :");
scanf("%d%d",&m,&n);
ans= m / /**/ /**/ ;
k=/**/ /**/ (ans*1000)%10;
printf("\n m/n=%f The 3th decimal place is: %d\n",ans,k);
getch();
}
第五题 将程序填写完整,实现∏ = 1 1 + 1 1 + 1 .....计算∏的近似值,直到最后一项的绝对值小于10^-6为止
4 1 3 5 7 9
程序代码:#include <stdio.h>
#include <math.h>
void main()
{ float k,n,pi;
int s;
pi=/**/ /**/ ;
s=1 ;
k=n=1.0;
while (fabs(k)>=1e-6)
{
pi=pi+k;
n=n+ /**/ /**/;
s=s* /**/ /**/;
k=s/n;
}
pi=pi*4;
printf("pi=%f\n",pi);
getch();
}
请各大哥解决一下题目 





