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

加入VIP,免费下载
 

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

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

下载须知

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

版权提示 | 免责声明

本文(C语言实训题16章.docx)为本站会员(b****2)主动上传,冰点文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰点文库(发送邮件至service@bingdoc.com或直接QQ联系客服),我们立即给予删除!

C语言实训题16章.docx

1、C语言实训题16章1.3.1:请参照本章例题,编写一个C程序,从键盘上输入圆的半径,求园的周长和以此半径所组成的球的体积。/* HELLO.C - Hello, world */#include stdio.h#include conio.hmain() float r,c,v,pi=3.14;printf(r:);scanf(%f,&r);c=2*pi*r;v=4.0/3*pi*r*r*r;printf(c=%fn,c);printf(v=%fn,v);getch();1.3.2:编写一个C程序,输入45,21,60三个数字,输出其中的最大者。/* HELLO.C - Hello, worl

2、d */#include stdio.h#include conio.hint max(int x,int y,int z)int m; m=xy?x:y; return(mz?m:z);main() int x,y,z;printf(x:);scanf(%d,&x);printf(y:);scanf(%d,&y);printf(z:);scanf(%d,&z);printf(max=%dn,max(x,y,z);getch();2.6.1.1:观察分析程序的结果,并与人工计算结果进行比较。/* HELLO.C - Hello, world */#include stdio.hvoid mai

3、n() char c1,c2; c1=97;c2=98; printf(%c %cn,c1,c2); printf(%d %dn,c1,c2); c1=c1-(a-A); printf(%c %cn,c1,c2); getch();2.6.2:参照下列求圆面积与园周长的程序,编写已知圆半径、圆柱高,求圆周长和圆柱体积的程序。/* HELLO.C - Hello, world */#include stdio.h#define pi 3.1415926void main() float r,h,v,len; printf( r:); scanf(%f,&r); printf( h:); scan

4、f(%f,&h); len=2*pi*r; v=pi*r*r*h; printf(n v=%f,length=%f,v,len); getch();3.7.1:编写程序,使得该程序运行后显示下面一首诗:life is dear indeed,love is priceless too,but for freedoms sake,I may part with the two./* HELLO.C - Hello, world */#include stdio.h#include conio.hmain() printf(life is dear indeed,nlove is priceles

5、s too,nbut for freedoms sake,nI may part with the two.); getch();3.7.2:用格式控制符打印下面图形: * * */* HELLO.C - Hello, world */#include stdio.h#include conio.hmain() printf( *n *n *n*); getch();3.7.3:编写程序,输入一个华氏温度(F),按下面的公式计算并输出对应的摄氏温度(C)。计算公式为C=5(F-32)/9。/* HELLO.C - Hello, world */#include stdio.h#include

6、conio.hmain() float F,C; printf(F:); scanf(%f,&F); C=5*(F-32)/9; printf(C=%fn,C); getch();4.5.1:编写程序,输入一个日期,判断该日期是这一年的第几天。/* HELLO.C - Hello, world */#include stdio.h#include conio.hmain() int day,month,year,sum,leap; printf(nplease input year,month,dayn); scanf(%d,%d,%d,&year,&month,&day); switch(m

7、onth) case 1:sum=0;break; case 2:sum=31;break; case 3:sum=59;break; case 4:sum=90;break; case 5:sum=120;break; case 6:sum=151;break; case 7:sum=181;break; case 8:sum=212;break; case 9:sum=243;break; case 10:sum=273;break; case 11:sum=304;break; case 12:sum=334;break; default:printf(data error); brea

8、k; sum=sum+day; if(year%400=0|(year%4=0&year%100!=0) leap=1; else leap=0; if(leap=1&month2) sum+; printf(it is the %dth dayn,sum); getch();4.5.2:编写程序,对于输入的三个数,将他们降序输出。/* HELLO.C - Hello, world */#include stdio.h#include conio.hmain() float x,y,z,temp; printf(Please input three number:n); scanf(%f,%f

9、,%f,&x,&y,&z); if (xy) temp=x; x=y; y=temp; if (xz) temp=x; x=z; z=temp; if (yz) temp=y; y=z; z=temp; printf(the sequence is:%3.1f,%3.1f,%3.1fn,z,y,x); getch();4.5.4:某大型电器公司在国庆节期间推出以下促销优惠活动:当天所购商品价值在20000元以上(包括20000元)的顾客,将享受7.5折优惠;当天所购商品价值在15000元以上(包括15000元)的顾客,将享受8折优惠;当天所购商品价值在10000元以上(包括10000元)的顾客

10、,将享受8.5折优惠;当天所购商品价值在5000元以上(包括5000元)的顾客,将享受9折优惠;其他顾客享受9.5折优惠。编写实现该优惠活动的程序。/* HELLO.C - Hello, world */#include stdio.h#include conio.hmain() float x; float y; printf(please input a x:n); scanf(%f,&x); if(x=20000) y=x*0.75; else if (x=15000) y=x*0.8; else if (x=10000) y=x*0.85; else if (x=5000) y=x*0

11、.9; else y=x*0.95; printf(%fn,y); getch(); 4.5.5:写出实现以下函数的对应程序,要求:输入x,计算并输出函数y的值(保留两位小数)。 X+10,(x0)/* HELLO.C - Hello, world */#include stdio.h#include conio.hmain() float x; float y; printf(please input a x:n); scanf(%f,&x); if(x0) y=x*30; else if(x=1000&x10000) a=x%10;printf(%dn,a); b=(x/10)%10;pr

12、intf(%dn,b); c=(x/100)%10;printf(%dn,c); d=(x/1000)%10;printf(%dn,d); y=b*1000+a*100+d*10+c;printf(%dn,y); else printf(sorry ERROR); getch();5.5.3.2:编一程序输出如下图形: 1121 12321 1234321 12345432112345654321/* HELLO.C - Hello, world */#include stdio.h#include conio.hmain() int i,j; for(i=1;i=6;i+) for(j=1;

13、j=6-i;j+) printf( ); for(j=1;j=1;j-) printf(%d,j); printf(n); getch();5.6.3:设计程序输出Fibonacci数列的前50个数,其开始两个数是1、1,从第三个数开始,每个数等于前两个数之和。例如,1、1、2、3、5、8、13、。/* HELLO.C - Hello, world */#include stdio.h#include conio.hint main()long x16 = 0,1;int i;for(i=2;i16;i+) xi = xi-1+xi-2;for(i=1;i16;i+)printf(F%d=%d

14、n,i,xi);getch ();5.6.7:用循环程序输出以下图案。 * * * * * */* HELLO.C - Hello, world */#include stdio.h#include conio.hvoid main()int a,b,c;for(a=1;a=4;a+)for(b=1;b=4-a;b+)printf( );for(c=2;c=2*a;c+)printf(*);printf(n);for(a=0;a=2;a+)for(b=0;b=a;b+)printf( );for(c=0;c=4-2*a;c+)printf(*);printf(n);getch();5.6.8:

15、用以下公式计算圆周率的近似值。/4=1-1/3+1/5-1/7+/* HELLO.C - Hello, world */#include stdio.h#include conio.hvoid main()double pi=0.0,i=1.0,j=1.0;for(;i100000000;i+=2,j=-j)pi+=1/(i*j);pi=pi*4;printf(pi=%lf,pi);getch();5.6.10:猴子吃桃问题。猴子第一天摘下若干桃子,当即吃了一半,还不过瘾,又多吃了一个。第二天将剩下的桃子吃了一半,又多吃了一个。以后每天都吃前一天剩下的一半零一个。到第十天再想吃时,就只剩下一个

16、桃子了求第一天共摘了多少桃子。/* HELLO.C - Hello, world */#include stdio.h#include conio.hmain() int n=1,i; i=0 ; while(i9) n=2*(n+1);+i; printf(%d,n); getch();6.5.1:有8位青年歌手参加歌曲大奖赛,有10个评委对他们的演唱进行打分,试编程序求各位选手的平均分(去掉一个最高分和一个最低分)。#include stdio.h#include conio.hmain() float i,n,k,s=0; float max ,min; float a10; print

17、f (please input 10 number:n) ; for(i=0;i10;i+) scanf(%f,&ai); max=a0;k=0; min=a0;n=0; for(i=0;imax) max=ai;k=i; for(i=0;i10;i+) if (aimin) min=ai;n=i; for(i=0;i10;i+) s=s+ai; s=(s-ak-an)/8.0; printf(%0.1f,s); getch();6.6.6.2:输入5*5的矩阵,编程实现:(1) 分别求两对角线上的各元素之和。(2) 求两对角线上行、列下标均为偶数的各元素之和。#include stdio.h

18、#include conio.hmain() int a55; int i,j,s1,s2,sum1=0; printf(1):n); printf(please input 25 numbers:n); for(i=0;i5;i+) for(j=0;j5;j+) scanf(%d,&aij); printf(n); s1=0,s2=0; for(i=0;i5;i+) for(j=0;j5;j+) if(i=j) s1=s1+aij; for(i=0;i=0;j-) if(i+j=4)s2=s2+aij; printf(s1=%d,s2=%d,s1,s2); printf(n); printf(2):n); for(i=0;i5;i+) for(j=0;j5;j+) if(i%2=0&j%2=0) sum1=sum1+aij; printf(sum1=%dn,sum1); getch();6.6.4:将一个数组中的值按逆序重新存放。#include stdio.h#include conio.hmain() int a10,b10; int i; printf(please input 10 number:n); for(i=0;i10;i+) scanf (%d,&ai); for(i=0;i10;i+) bi=a9-i; printf(%d ,bi); getch();

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2