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

加入VIP,免费下载
 

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

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

下载须知

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

版权提示 | 免责声明

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

华科周纯杰版c语言答案.docx

1、华科周纯杰版c语言答案第三章 程序和流程控制 1.输入两个整数,输出较大者。 #include void main() int a,b; int max=0; printf(Please input two numbers:); scanf(%d%d,&a,&b); if(a=b) max=b; else max=a; printf(The larger number is %dn,max); 2.有3个整数a,b,c,由键盘输入,输出其中最大的数。 #include void main() int a,b,c,max; printf(Please input three numbers:);

2、 scanf(%d%d%d,&a,&b,&c); if(ab) if(ac) max=a; else max=c; else if(bc) max=b; else max=c; printf(The largest number is %dn,temp);3.从1累加到100,用while语句。 #include #define N 100 void main() int i=1,sum=0; while(i=N) sum+=i; i+; printf(sum:%dn,sum);4.已知a110,a2 3,an3an-1 an-2 ,求 a 的前十项。 #include #define N 1

3、0 void main() int a20=10,-3; int i=0,m=0; for(i=2;iN;i+) ai=3*ai-1+ai-2; m=N; printf(The %d numbers are:n,m); for(i=0;iN;i+) printf(a%d=%dn,i+1,ai); 5.输入一个自然数,判断它是奇数还是偶数。 #include void main() int a, temp; printf(Please input a numbers:n); scanf(%d,&a); temp=a%2; if(temp=0) printf(The number %d is an

4、 even!n,a); else printf(The number %d is an odd number!n,a); 6.已知a1 8,an an-1 bn ,b1 1,bn bn-1 3,求 a 前10项之和。 #include #define N 10 void main() int aN=8,bN=1,i,sum=0; for(i=1;iN;i+) bi=bi-1+3; for(i=1;iN;i+) ai=ai-1+bi; for(i=0;iN;i+) sum+=ai; printf(The sum is:%dn,sum); 7.有一个函数 写一程序,输入x,输出Y的值。 #incl

5、ude void main() float x,y; printf(Please input a float number x=:); scanf(%f,&x); printf(x=%f,x); if(x=10) y=3*x-11; else y=2*x-1; printf(The value of y is:%.3fn,y); 8.给一个不多于5位的的正整数,要求:求出它是几位数,分别打印出每一位数字,最后按照逆序打印各位数字,例如原数为321,应输出为123。 #include #define N 99999 #define M 5 void main() int i,j,k,m,bM;

6、long int a,temp; printf(Please input a number:n); scanf(%ld,&a); if(aN) printf(Error in input data!n); else temp=a; for(i=0;temp!=0;i+) temp=temp/10; m=i; printf(The number a=%ld have %d single numbersn,a,m); temp=a; for(j=0;j=0;j-) printf(%dt,bj); printf(n); printf(The inverted numbers are:n); for(

7、j=0;jm;j+) printf(%d,bj); printf(n); 9 编写一猜数游戏程序,随机产生某个整数,从键盘反复输入整数进行猜数,当未猜中时,提示输入过大或过小.猜中时,指出猜的次数.最多允许猜20次. #include #include #include #define N 10 void main() int a,b,i; randomize(); a=random(N); printf(Please input number you guess:n); for(i=0;ia) printf(Your number is too big!n); else printf(You

8、r number is too small!n); printf(n); 10.计算1999中能被3整除,且至少有一位数字是5的所有整数。 #include #define N 999 void main() int i,b,c,d; printf(The numbers are:n); for(i=1;i=N;i+) if(i%3) b=i/100; c=(i-100*b)/10; d=i%10; if(b=5|c=5|d=5) printf(%dt,i); 11.输入两个整数,求它们的最大公约数和最小公倍数。 #include void main() int a,b,c,d; int co

9、mYueShu; int comBeishu; printf(please input two number!); scanf(%d %d,&a,&b); c=a; d=b; int r; 入一个整数,求它包含又多少个2的因子。(例如,8含有3个2的因子,10含有一个2的因子,15不含有2的因子。) #include void main() int a=0; int integerGene=0; printf(input a number!n); scanf(%d,&a); while(a%2=0) integerGene+; a/=2; printf(%dn,integerGene);13.

10、计算1!,2!,3!10! #include #define N 10 void main() int i; long int a=1; printf(The outcome are:n); for(i=1;i=10;i+) a*=i; printf(The result of %d! is %ldn,i,a); 14.猴子吃桃问题:第一天吃掉总数的一半多一个,第二天又将剩下的桃子吃掉一半多一个,以后每天吃掉前一天剩下的一半多一个,到第十天准备吃的时候见只剩下一个桃子,求第一天开始吃的时候桃子的总数。 #include #define N 10 void main() int i,x10; x

11、9=1; for(i=9;i=1;i-) xi-1=2*(xi+1); printf(The total numbers in the first day are:%dn,x0);15.输入圆锥体的底半径r和高h,计算出圆锥体的体积并输出 #include #define PI void main() float r,h,v; printf(Please input the radius and the height:n); scanf(%f%f,&r,&h); v=PI*r*r*h/3; printf(The volume of is %.6fn,v); 16题 #include void

12、main() int a,n; long tmp,SUM=0; do printf(nPlease input the number a=); scanf(%d,&a); while(!(a=0 & a=9); printf(nPlease input the number,its value is not too big n=); scanf(%d,&n); tmp = a; while(n-) SUM += tmp; tmp = tmp * 10 + a; printf(na+aa+aaa+.=%ld(a= %d)n,SUM,a);17题 #include void main() unsi

13、gned char week720=Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,saturday; unsigned char weekday; do printf(nPlease input the weeday(0 =the value of weekday = 0 & weekday 1e-6); printf(nThe natural constant e, its %f pow = %f,x,Result);19题 #include #include void main() float a; float x1,x2; printf(

14、nPlease input the number a=); scanf(%f,&a); x1 = x2 = a/2; do x1=x2; x2=(x1+(a/x1)/2; while(fabs(x2 - x1) 1e-5); printf(nInput a namber %f,Its sqrt = %f,a,x2); 第5章课后编程习题参考答案2.已有一个已排好序的数组,现在输入一个数,要求按照原来排序的规则将它插入数组中。 #include #define N 7 void main() int aN=1,5,16,45,87,120; int n,i,j,temp1,temp2,end;

15、printf(please enter a number:n); scanf(%d,&n); end=aN-2; if(nend) aN-1=n; else for(i=0;iN-1;i+) if(ni+1;j-) aj=aj-1; ai=n; break; printf(put out the new array:n); for(i=0;iN;i+) printf(%4d,ai);3.打印魔方阵,所谓魔方阵是指这样的方阵,它的每一行,每一列和对角线之和均相等。例如,三阶魔方阵为: 8 1 6 3 5 7 4 9 2 #include void main() int a1616; int n,

16、i,j,k; do printf(enter a number n(115):n); scanf(%d,&n); while(!(n0)&(n=15)&(n%2=1); for(i=1;i=n;i+) for(j=1;j=n;j+) aij=0; j=n/2+1; a1j=1; for(k=2;k=n*n;k+) i=i-1; j=j+1; if(in) i=i+2; j=j-1; else if(in) j=1; if(aij=0) aij=k; else i=i+2; j=j-1; aij=k; for(i=1;i=n;i+) for(j=1;j=n;j+) printf(%4d,aij)

17、; printf(n); 4,有一篇文章,共有3行文字,每行有80个字符,要求分别统计出其中英文大写字母,小写字母,数字,空格以及其它字符的个数。 #include #include void main() char s380; int i,j,up,low,num,spa,oth; up=low=num=spa=oth=0; for(i=0;i3;i+) printf(enter the %d line:n,i+1); gets(si); for(j=0;j=A&sij=a&sij=0&sij=9) num+; else if(sij= ) spa+; else oth+; printf(u

18、p=%dn,up); printf(low=%dn,low); printf(num=%dn,num); printf(spa=%dn,spa); printf(oth=%dn,oth); 5.编写一个程序,将两个字符串连起来,不要用strcat函数。 #include #include void main() char s1100,s2100; gets(s1); gets(s2); int i,j; i=j=0; while(s1i!=0) i+; while(s2j!=0) s1i+=s2j+; s1i=0; puts(s1); 6.输入每个学生的平均成绩和姓名,将成绩按照递减顺序排序,

19、姓名做相应的调整。输出排序后的成绩和姓名。 #include #include define N 10 /* 假定有十个学生*/ void main() char name5010,name110; int markN,i,j,mark1; for(i=0;iN;i+) printf(the %d th students name and mark:n,i+1); scanf(%s%d,namei,&marki); for ( i=0;iN-1;i+) for (j=i+1;jmarki) mark1 = markj; markj = marki; marki = mark1; strcpy(

20、name1,namej); strcpy(namej,namei); strcpy(namei,name1); for(i=0;iN;i+) printf(%s,%dn,namei,marki); 7.输出2维数组中行为最大列上为最小的元素(称为鞍点)及其位置。如果不存在任何鞍点,则也应输出相应信息。 #include void main() int i,j,k,m,n,max,maxj; int a1010; int flag=0; printf(enter the hang number n:n); scanf(%d,&n); printf(enter the lie number m:n

21、); scanf(%d,&m); for(i=0;in;i+) for(j=0;jm;j+) scanf(%d,&aij); printf(n); for(i=0;in;i+) max=ai0; for(j=0;jmax) max=aij; maxj=j; for(k=0;kakmaxj) break; if(k=n) printf(nthe %d hang,the %d lie ,the number %d is an dian!n,i, maxj,max); flag=1; if(!flag) printf(no an dian!);8.计算矩阵A 的转置矩阵A ,例如:A= , A = #include void main() int a43,b34; int i,j; printf(enter array a:n); for(i=0;i4;i+) for(j=0;j3;

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

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