16年c语言考试试题,C语言试题、学、考试大全16.doc

C语言试题、学、考试大全16

数学公式的题目:

编写函数fun,函数的功能是:根据以下公式计算s,计算结果作为函数值返回;n通过形参传入。s 1+1/ 1+2 +1/ 1+2+3 +.......+1/ 1+2+3+4+......+n 例如:若n的值为11时,函数的值为1.833333。

float fun int n int i,sum 1; float s 1; for i 2;i n;i++ sum sum+i; s s+1.0/sum; return s; long chsdc int n int i,s; s 0; for i 0;i n;i++ s s+i; return s ;

改:[1]double sum 0.0;sum/ c; '\0' [2] 0 [3] i

请编写函数fun,它的功能是:求Fibonacci数列中大于t的最小的一个数,结果由函数返回。其中Fibonacci数列F n 定义为:F 0 0,F 1 1,F n F n-1 +F n-2

例如:当t 1000时,函数值为1597。

int fun int t

int i,s 0; for i 0;s t;i++ s f i ; return s; 改:[1]s s+ double n+1 /n;return t;请编写函数fun,它的功能是:求出1到1000之内能被7或11整除、但不能同时被7和11整除的所有整数并将它们放在a所指的数组中,通过n返回这些数的个数。

void fun int *a,int *n int i,m 0;

for i 1;i 1000;i++

if i%7 0 || i%11 0 && ! i%7 0 && i%11 0 a[m] i;m+ 1;

*n m;

改:[1] t *x;*x y; return t ;

编写函数fun,它的功能是:利用以下所示的简单迭代方法求方程cos x -x 0的一个实根。Xn+1 cos Xn

迭代步骤如下:取x1初值为0.0;x0 x1,把x1的值赋给x0;x1 cos x0 ,求出一个新的x1; 若x0-x1的绝对值小于0.000001,则执行步骤 5 ,否则执行步骤 2 ;所求x1就是方程cos x -x 的一个实根,作为函数值返回。float fun float x0,x1 0; do x0 x1; x1 cos x0 ; while fabs x0-x1 1e-006 ; return x1;

改:[1] void fun char *a [2] printf "%c",*a ;

请编写函数fun,它的功能是计算下列级数和,和值由函数值返回。例如,当n 10,x 0.3时,函数值为1.349859。 double fun double x, int n int i; float p 1; long q 1; double t,s 1.0; for i 1; i n; i++ p* x; q* i; t p/q; s+ t; return s; double fun int n [2] return sum;

请编写函数fun,它的功能是计算:s ln 1 +ln 2 +1n 3 +…+ln m 0.5 s作为函数值返回。在C语言中可调用log n 函数求ln n 。log函数的引用说明是:double log double x 。例如,若m的值为20,则fun函数值为6.506583。double fun int m double i;double r,s; double log double i ; for i 1;i m;i++ r r+log i ; return sqrt r ; 改:[1] double f double x [2] return s;

请编写一个函数fun,它的功能是:根据以下公式求π的值 要求满足精度0.0005,即某项小于0.0005时停止迭代 :

X/2 1+1/3+1×2/3×5+1×2×3/3×5×7+1×2×3×4/3×5×7×9+...+1×2×3×...×n/3×5×7× 2n+1

程序运行后,如果输入精度0.0005,则程序输出为3.14…。double fun double eps double s; float n,t,pi; t 1;pi 0;n 1.0;s 1.0; while fabs s eps pi+ s; t n/ 2*n+1 ; s* t; n++; pi pi*2; return pi; 改:[1] int fun char*str,char*substr fo

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值