ImageVerifierCode 换一换
格式:DOCX , 页数:4 ,大小:29.78KB ,
资源ID:6970514      下载积分:10 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.docduoduo.com/d-6970514.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录   微博登录 

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(程序填空.docx)为本站会员(11xg27ws)主动上传,道客多多仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知道客多多(发送邮件至docduoduo@163.com或直接QQ联系客服),我们立即给予删除!

程序填空.docx

1、程序填空填空1. 函数 fun 的功能是:计算的前 n 项之和,若 x=2.5,n=15 时,函数值!)1(!)1(.!4321)( 2xnxxxf n为:1.917914.#include #include double fun(double x, int n) double f, t; int i;/*found*/f = _1_; /答案 1t = -1;for (i=1; i#include double fun(double x) double f, t; int n; f = 1.0 + x;/*found*/t = _1_; /答案 xn = 1;do n+;/*found*/t

2、 *= (-1.0)*x/_2_; /答案 nf += t;/*found*/while (_3_ = 1e-6); /答案 fabs(t)return f;main() double x, y;x=2.5; y = fun(x);printf(“nThe result is :n“);printf(“x=%-12.6f y=%-12.6fn“, x, y);1. 函数 fun 的功能是:计算 的前 n 项。若 x=2.5,函数值为:12.182340!.21xxf#include double fun(double x, int n) double f, t; int i;f = 1.0;/

3、*found*/t = _1_; /答案 1/*found*/for (i=_2_; i#include double fun(double x) double f, t; int n;/*found*/f = 1.0+_1_;/答案 xt = x;n = 1;do n+;/*found*/t *= x/_2_;/答案 n/*found*/f += _3_;/答案 t while (fabs(t) = 1e-6);return f;main() double x, y;x=2.5;y = fun(x);printf(“nThe result is :n“);printf(“x=%-12.6f

4、y=%-12.6f n“, x, y);1. 函数 fun 的功能是:统计所有小于等于 n(n2)的素数的个数,素数的个数作为函数值返回。#include int fun(int n) int i,j, count=0;printf(“nThe prime number between 3 to %dn“, n);for (i=3; i=i) /答案 j count+; printf( count%15? “%5d“:“n%5d“,i); return count;main() int n=20, r;r = fun(n);printf(“nThe number of prime is : %

5、dn“, r);函数 fun 的功能是:统计长整数 n 的各个位上出现数字 1、2、3 的次数,并通过外部(全局)变量c1,c2,c3 返回主函数。例如:当 n=123114350 时,结果应该为:c1=3 c2=1 c3=2#include int c1,c2,c3;void fun(long n) c1 = c2 = c3 = 0;while (n) /*found*/switch(_1_) /答案 n%10/*found*/case 1: c1+;_2_;/答案 break/*found*/case 2: c2+;_3_;/答案 breakcase 3: c3+;n /= 10;main

6、() long n=123114350L;fun(n);printf(“nThe result :n“);printf(“n=%ld c1=%d c2=%d c3=%dn“,n,c1,c2,c3);1. 函数 fun 的功能是:从三个形参 a,b,c 中找出中间的那个数,作为函数值返回。例如,当a=3,b=5,c=4 时,中数为 4.#include int fun(int a, int b, int c)int t;/*found*/t = (ab) ? (bc? b :(ac?c:_1_) : (ac)?_2_ : (bc)?c:_3_);/答案 c:a a c:breturn t;mai

7、n() int a1=3, a2=5, a3=4, r;r = fun(a1, a2, a3);printf(“nThe middle number is : %dn“, r);1. 给定程序中,函数 fun 的功能是:找出 100 至 x(x999)之间各位上的数字之和为 15 的所有整数,然后输出:符合条件的整数个数作为函数值返回。例如,当 n 值为 500 时,各位数字之和为 15 的整数有:159、168、177、186、195、249、258、267、276、285、294、339、348、357、366、375、384、393、429、438、447、456、465、474、483

8、、492.共有 26 个#include int fun(int x) int n, s1, s2, s3, t;/*found*/n=_1_; /答案 0t=100;/*found*/while(t999|xint fun(int x) int n, s1, s2, s3, t; n=0; t=100;/*found*/while(t0): “); scanf(“%d“, printf(“nThe result is: %dn“,fun(x);给定程序中,函数 fun 的功能是:将形参 n 中,各位上为偶数的数取出,并按原来从高位到低位的顺序组成一个新的数,并作为函数值返回。例如,从主函数输

9、入一个整数:27638496,函数返回值为:26846#include unsigned long fun(unsigned long n) unsigned long x=0, s, i; int t;s=n;/*found*/i=_1_;/答案 1/*found*/while(_2_)/答案 s t=s%10;if(t%2=0)/*found*/x=x+t*i; i=_3_;/答案 i*10s=s/10;return x;main() unsigned long n=-1;while(n99999999|ndouble fun(int n) int i; double s, t;/*found*/s=_1_;/答案 0/*found*/for(i=1; i0): “); scanf(“%d“, printf(“nThe result is: %fn“,fun(n);

本站链接:文库   一言   我酷   合作


客服QQ:2549714901微博号:道客多多官方知乎号:道客多多

经营许可证编号: 粤ICP备2021046453号世界地图

道客多多©版权所有2020-2025营业执照举报