教学文库网 - 权威文档分享云平台
您的当前位置:首页 > 精品文档 > 高等教育 >

C语言习题全集 答案(至函数)讲解(9)

来源:网络收集 时间:2025-12-28
导读: 二、 读程序写结果 1. fun1(int a,int b) { int c; a+=a; b+=b; c=fun2(a,b); return c*c; } fun2(int a,int b) { int c; c=a*b%3; return c; } main() { int x=11,y=19; printf(\ } 2. int x; main() { x=5; cud

二、 读程序写结果 1. fun1(int a,int b) { int c;

a+=a; b+=b; c=fun2(a,b); return c*c; }

fun2(int a,int b) { int c; c=a*b%3; return c; } main()

{ int x=11,y=19;

printf(\ }

2. int x;

main() { x=5; cude();

printf(\ } cude()

{ x=x*x*x; }

3. #include

long fun(int n)

{ long s;

if(n==1||n==2)

s=2; else

s=n+fun(n-1); return s; }

main()

31

{ printf(\

}

4. main() { int i;

for(i=0;i<2;i++) add();

} add() { int x=0;

static int y=0; printf(\x++; y=y+2;

}

5. main()

{ int k=4,m=1,p;

p=func(k,m); printf(\p=func(k,m); printf(\

}

func(int a,int b) { static int m=0,i=2;

i+=m+1; m=i+a+b; return m;

}

6. int t(int x,int y,int cp,int dp)

{ cp=x*x+y*y; dp=x*x-y*y; }

main()

{ int a=4,b=3,c=5,d=6; t(a,b,c,d);

printf("%d%d\\n",c,d); }

32

7. fun(int x,int y,int z)

{z=x*x+y*y;} main()

{ int a=31;

fun(5,2,a); printf("%d",a); }

8. int a,b;

void fun()

{ a=100;b=200; } main()

{ int a=5,b=7; fun();

printf("%d%d\n",a,b); }

9. int x=3;

main() {int i;

for(i=1;i

{static int x=1; x*=x+l;

printf("%d",x); }

10. int func(int a,intb)

{ return(a+b); } main()

{int x=2,y=5,z=8,r; r=func(func(x,y),z); printf("%d\n",r); }

11. long fib(int n)

{ if(n>2)return(fib(n-1)+fib(n-2)); else return(2); }

33

main()

{ printf("%ld\\n",fib(3)};}

三、 填空题

1. 编写一个验证正整数M是否为素数的函数,若M是素数则把1送到T中,否则零送到

T中。在主函数中读入N个正整数,每读入一个则调用函数判断它是否为素数,在主函数中将T的值累加到另一个变量中。用此方法可求出N个数中素数的个数。请填空完成上述功能的程序。 #include

C语言习题全集 答案(至函数)讲解(9).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.jiaowen.net/wendang/608698.html(转载请注明文章来源)
Copyright © 2020-2025 教文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:78024566 邮箱:78024566@qq.com
苏ICP备19068818号-2
Top
× 游客快捷下载通道(下载后可以自由复制和排版)
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能出现无法下载或内容有问题,请联系客服协助您处理。
× 常见问题(客服时间:周一到周五 9:30-18:00)