欢迎来到淘文阁 - 分享文档赚钱的网站! | 帮助中心 好文档才是您的得力助手!
淘文阁 - 分享文档赚钱的网站
全部分类
  • 研究报告>
  • 管理文献>
  • 标准材料>
  • 技术资料>
  • 教育专区>
  • 应用文书>
  • 生活休闲>
  • 考试试题>
  • pptx模板>
  • 工商注册>
  • 期刊短文>
  • 图片设计>
  • ImageVerifierCode 换一换

    华中科技大学规范标准C语言知识程序设计及应用习题集标准答案.doc

    • 资源ID:2640237       资源大小:115.02KB        全文页数:32页
    • 资源格式: DOC        下载积分:10金币
    快捷下载 游客一键下载
    会员登录下载
    微信登录下载
    三方登录下载: 微信开放平台登录   QQ登录  
    二维码
    微信扫一扫登录
    下载资源需要10金币
    邮箱/手机:
    温馨提示:
    快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。
    如填写123,账号就是123,密码也是123。
    支付方式: 支付宝    微信支付   
    验证码:   换一换

     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    华中科技大学规范标准C语言知识程序设计及应用习题集标准答案.doc

    第二章一.选择题1.C 2.B D 3.A 4.A 5. D 6.C 7.D 8.C 9.A 10.D11.B 12.D 13.C 14.D 15.A16.B 17.A 18.B 100011 001111二.判断题1.错2.错3.错4.错三.填空题1. B 662. n1=%dnn2=%dn3. 0四.计算1(1) x|y = 0x002f(2) xy = 0x0026(3) x&y = 0x0009;(4) x+y = 0xffc6(5) x<<=3 0x0068(6) y>>=4 0x00022(1) 6(2) 50(3) 1(4) 16(5) 1(6) 203(1) 0(2) 1(3) 1(4) 4(5) 8(6) 14(1) 12(2) 0(3) 1(4) 27(5) 1(6) 6(7) 24(8) 27(9) 295(1) 0(2) 1(3) 1(4) 3(5) 2五.程序分析题程序1b=20 a=3600 程序2第三章一.填空题1.s=62.963.(1) scanf("%c",&c); (2) c-32 更好的答案:c-(a-A)2.1 main()int a,b;printf("please input a & b:");scanf("%d%d",&a,&b);printf("nmax is %dn",(a>b)?a:b);2.2int max(int x,int y);main()int a,b,c,max;printf("please input a & b & c:");scanf("%d%d%d",&a,&b,&c);max=a>b?a:b;max=c>max?c:max;printf("nmax is %dn",max);2.3main() int i=0,sum=0; while(i<=100) sum+=i; i+; printf("1+2+3+.+100=%dn",sum);2.4main() int i; int a=10,b=-3; int c; printf("%6d%6d",a,b); for(i=2;i<10;i+) c=3*b+a; printf("%6d",c); a=b; b=c; printf("n");2.5main() int i; while(1) printf("please input a data(0:exit):"); scanf("%d",&i); if(i=0) break; if(i%2=0) printf("the data %d is a even number.n",i); else printf("the data %d is a odd number.n",i); 2.6#include <stdio.h>main() int i; int a=8,b=1; int sum=0; for(i=0;i<10;i+) b+=3; sum += a; a+=b; printf("a%8d b:%8dn",a,b); printf("The Sum Of Is:%dn",sum);2.7#include <stdio.h>main() float x,y; printf("please input x:"); scanf("%f",&x); if(x<1.0) y=x; else if(x<10) y=2*x-1; else y=3*x-11; printf("y=%fn",y);2.8#include <stdio.h>main() long a,i,b,a1; while(1) printf("please input data(1-99999):"); scanf("%ld",&a); printf("a:%ldn",a); if(a<=0|a>=100000) break; i=0; a1=0; while(a!=0) b=a%10; printf("%8d",b); a/=10; i+; a1=a1*10+b; printf("n i:%ld a1:%ldn",i,a1); 2.9#include <stdio.h>#include <time.h>#include <stdlib.h>main() int a,b,i,k=0; randomize(); a=random(1001);/*create a random data(0-1000)*/ for(i=0;i<20;i+) printf("please guess a number:"); scanf("%d",&b); if(a>b) k+; printf("n%d:Smaller,guess again!n",k); else if(a<b) k+; printf("n%d:Bigger,guess again!n",k); else printf("nYou guess right,congraturation!") ; printf("nYou have guessed %d times",k); break; if(k=20) printf("nsorry,you failed!");2.10#include <stdio.h>main() int a,b,c; int num; for(a=0;a<10;a+) for(b=0;b<10;b+) for(c=1;c<10;c+) num=a*100+b*10+c;if(num%3=0)&&(a=5|b=5|c=5) printf("%8d",num); printf("nnn");2.11#include <stdio.h>main() int i; int a,b; printf("please input a,b:"); scanf("%d%d",&a,&b); for(i=a<b?a:b;i>0;i-) if(a%i=0&&b%i=0) printf("The max=%d",i); break; for(i=a>b?a:b;i>0;i+) if(i%a=0&&i%b=0) printf("nThe min=%d",i); break; 2.12#include <stdio.h>main() int a,k=0; printf("please input data:"); scanf("%d",&a); while(a%2=0) a=a/2; k+; printf("nthe number of factor(2) is %d",k);2.13main() long i,t=1; long sum=0; for(i=1;i<=10;i+) t*=i; sum+=t; printf("%ld!=%ldn",i,t); printf("sum:%ldn",sum); 2.14#include <stdio.h>void main() int i,x=0; for(i=9;i>=1;i-) x=2*(x+1); printf("The first day:%d",x);2.15#include <stdio.h>#define PI 3.141593main() float r,h; float v; printf("please input r,h:"); scanf("%f%f",&r,&h); v=1.0/3*PI*r*r*h; printf("V=%.2f",v);2.16#include<stdio.h>#include<math.h>main() long int sn=0; long int m=0,t=0; int a,n,i; printf("please input a n:"); scanf("%d%d",&a,&n); for(i=0;i<n;i+) m=m*10+a; sn+=m; printf("a+aa+aaa+.+aa.a=%ldnn",sn);2.17#include <stdio.h>main() int k; printf("please input k:"); do scanf("%d",&k); if(k>=0&&k<=6) break; while(1); switch(k) case 0:printf("Sunday.n");break; case 1:printf("Monday.n");break; case 2:printf("Tuesday.n");break; case 3:printf("Wednesday.n");break; case 4:printf("Thursday.n");break; case 5:printf("Friday.n");break; case 6:printf("Saturday.n");break; 2.18#include <stdio.h>main() int i; double x,a,b=1,sum=1; printf("please input x:"); scanf("%lf",&x); a=x; for(i=1;a/b>=1e-6;i+) sum=sum+a/b; a=a*x; b=(i+1)*b; printf("nsum=%lf",sum);2.19#include <stdio.h>#include <math.h>main() float a,x1,x2; printf("input a:"); scanf("%f",&a); x1=1.0; while(1) x2=1.0/2*(x1+a/x1); if(fabs(x2-x1)<1e-5) break; x1=x2; printf("sqrt(a)=%f",x2);第四章写出下列程序输出结果1.no 1 a=1no 1 a=0no 1 a=1no 1 a=02.a=0 b=0 c=0a=1 b=0 c=0a=2 b=0 c=03.main:x=5,y=1,n=1func:x=6,y=21,n=11main:x=5,y=1,n=11func:x=8,y=31,n=21第五章1.D2.D3.C4.65.CDABC6.(1)j+=2 (2)ai<aj7.(1)si+!=0 (2)si-1 8.D9.B10.6(同题4)11.si>=0&&si<=912. (1)0 (2)str1i-str2i5.1#include<stdio.h>int fun();int fun() int a33,sum; int i,j; sum=0;/*error*/ for(i=0;i<3;i+) for(j=0;j<3;j+) scanf("%d",&aij);/*error*/ for(i=0;i<3;i+) sum=sum+aii; printf("sum=%dn",sum);void main() fun();5.2#include <stdio.h>void main( void ) float Num10; float Input,GetNum11; int i,j; float a=6;for(i=0; i<10; i+) Numi=a; a=a+7.5;Loop1: printf("Please input a Number(0-80) Input="); scanf("%f",&Input);if(Input<0)|(Input>70)=1)goto Loop1;for(i=0; i<10; i+ )if(Input<Numi)goto Loop2;Loop2: for(j=0; j<i; j+ ) GetNumj=Numj;GetNumj=Input;for(j=i; j<=10; j+,i+)GetNumj+1=Numi;for(j=0; j<11; j+ )printf("%3.3f ",GetNumj);5.3#include "stdio.h"#include "stdlib.h"main()int a1,a2,a3,a4,a5,a6,a7,a8,a9;int a3;int i;for(;)for (i=0;i<3;i+)ai=rand()%3;while(a0!=a1) && (a0!=a2) && (a1!=a2)/*get three different numbers 0,1,2*/a1=a0+1;/*divide 19 into three groups,a1a3,a4a6,a7a9*/a2=a1+1;a3=a2+1;a4=a1+3;a5=a2+3;a6=a3+3;a7=a1+6;a8=a2+6;a9=a3+6;/* make sure that each line and each row is made up with three members in different group.*/* such as: a9 a1 a5 a2 a6 a7 a4 a8 a3 */if(a1+a5+a9) = (a2+a6+a7) && (a1+a5+a9) = (a3+a4+a8)&& (a1+a6+a8) = (a5+a7+a3) && (a1+a5+a9) = (a2+a4+a9)printf("%d %d %dn%d %d %dn%d %d %dn",a9,a1,a5,a2,a6,a7,a4,a8,a3);return;5.4#include <stdio.h>void main(void)char input1100,input2100,input3100;int i,Eng=0,eng=0,num=0,blank=0,other=0;printf("Input 3 rows of character,each row dont exceed 80 characters:n");gets(input1); printf("The second row:n"); gets(input2); printf("The third row:n"); gets(input3);/*test the first row*/for(i=0; i<100; i+) if(input1i=0) goto Loop1; else if(A<=input1i)&&(input1i<=Z)=1)Eng+; else if(a<=input1i)&&(input1i<=z)=1) eng+; else if(0<=input1i)&&(input1i<=9)=1)num+; else if(input1i=32)blank+; else other+;/*test the second row*/Loop1:for(i=0; i<100; i+) if(input2i=0) goto Loop2; else if(A<=input2i)&&(input2i<=Z)=1)Eng+; else if(a<=input2i)&&(input2i<=z)=1) eng+; else if(0<=input2i)&&(input2i<=9)=1)num+; else if(input2i=32)blank+; else other+;/*test the third row*/Loop2:for(i=0; i<100; i+) if(input3i=0) goto Loop3; else if(A<=input3i)&&(input3i<=Z)=1)Eng+; else if(a<=input3i)&&(input3i<=z)=1) eng+; else if(0<=input3i)&&(input3i<=9)=1)num+; else if(input3i=32)blank+; else other+;Loop3: printf("Upper english character:%dnLower english character:%dnNumber:%dnBlank:%dnOther characters:%dn",Eng,eng,num,blank,other);5.5#include <stdio.h>void main(void)char str180,str240;int i,j,k;/*Input two string*/printf("Please input the first stringn str1=");gets(str1);printf("Please input the second stringn str2=");gets(str2);/*Get the end of str1*/for(i=0; i<80; i+)if(str1i=0) break;/*Copy str2 to str1*/ for(j=i,k=0; str2k!=0;k+,j+) str1j=str2k; str1i+k=0; puts(str1);5.6#include <stdio.h>struct student char name20; int score;stu5,stu1;void main(void) int i,j;printf("Input students score and name(5),seperate using the character of , :n");for(i=0; i<5; i+) scanf("%d,%s",&stui.score,&stui.name);/*sorting*/for(i=0; i<5; i+) for(j=0; j<4-i; j+) if(stuj.score>stuj+1.score) stu1=stuj;stuj=stuj+1;stuj+1=stu1;printf("After sotred,score and name:n"); for(i=0; i<5; i+)printf("%d,%sn",stui.score,stui.name);5.7#include<stdio.h>main() int a33,i,j,m,n,o,p; printf("Please input a 3*3 shuzu:n"); for (i=0;i<=2;i+) for (j=0;j<=2;j+) scanf("%d",&aij); for (i=0;i<=2;i+) m=(ai0>ai1)? ai0:ai1; n=(m>ai2)? m: ai2; for (j=0;j<=2;j+) o=(a0j<a1j)? a0j:a1j; p=(o<a2j)? o: a2j; if (n=p) printf("Andian is %dn",p); else printf("There is no andian.n");5.8#include <stdio.h>void main(void) int a43,b34,i,j; for(i=0; i<4; i+) for(j=0; j<3; j+) scanf("%d",&aij); for(i=0; i<4; i+) printf("n"); for(j=0; j<3; j+) printf("%5d ",aij); for(i=0; i<4; i+) for(j=0; j<3; j+) bji=aij; printf("n");for(i=0; i<3; i+) printf("n"); for(j=0; j<4; j+) printf("%5d ",bij); 5.9#include <stdio.h>#include<math.h>void main(void) char str6; int i,j=0,m=0,n=0; gets(str); while(strj!=0) j+; for(i=j-1;i>=0;i-) m=(stri-0)*(pow(8,j-i-1); n+=m; printf("shijinzhi %d",n);5.10#include <stdio.h>void main(void)char input1100;int i,num=0,blank=0;printf("Please input a row character:n");gets(input1);/*test the first row*/for(i=0; i<100; i+) if(input1i=0) goto Loop; else if(A<=input1i)&&(input1i<=Z)=1)num+; else if(a<=input1i)&&(input1i<=z)=1) num+; else if (input1i=32)blank+;Loop: printf("Character:%dnBlank:%dn",num,blank);第六章一、 选择题1.D:p中记录的是a的地址,*p访问地址a的值2.D :指针数组3.D:指针可以进行是否相等判断,空指针可以进行指针变量初始化,指针可以偏移;4.C:5.C、D:a5不存在,若*&a4则正确;C,D正确;6.D:7.B:8.B:二、 填空题1*(p+3)2222 cdefgbcdefgabcdefg73 6385三、 程序分析题1p = s0 ; 错误,应改为:p = s; 或 p = &s0;2int x , *p;错误,应改为:double x, *p;3*p = x ;错误,应改为:p = &x ;4 声明顺序错误;应该改为:void main(void) int a; int *p = &a; a = 10; printf(“%dn”,*p);2.3 #include <stdio.h>#include <string.h>main() char ch25 = "6937","8254",*p2; int i,j,s=0; for(i=0;i<2;i+) pi = chi; for(i=0;i<2;i+) for(j=0;pij>0;j+=2) s = 10*s + pij - 0; printf("%dn",s);4.1#include <stdio.h>#include <string.h>main() int count = 0; char str1100,str2100; char *p1,*p2; printf("please enter string 1:"); gets(str1); printf("please enter string 2:"); gets(str2); printf("str1:%sn",str1); printf("str2:%sn",str2); p1 = str1; p2 = str2; while(*p1!=0&&*p2!=0) if(*p1+=*p2+) count+; printf("count:%dn",count);4.2#include <stdio.h>#include <string.h>main() int i,j,k; int a3; int temp; printf("please enter array a3:"); scanf("%d%d%d",&a0,&a1,&a2); for(i=0;i<2;i+) k = i; for(j= i+1;j<3;j+) if(aj<ai)k = j; if(k!=i) temp = ai; ai = ak; ak = temp; for(i=0;i<3;i+) printf("%dt",ai); printf("n");4.3#include <stdio.h>#include <string.h>#define N 100main() char s1N, s2N,*p; int m; printf("please enter string1:"); gets(s1); p = s1; printf("enter m:"); scanf("%d",&m); strcpy(s2,p+m); printf("string2:%sn",s2);4.4#include <stdio.h>#include <string.h>main() char s100="iuiui012asdd90k890y098kkkk1234",*p; char data100100=0; int count=0; int i; p = s;/* printf("please enter a string:"); gets(p);*/ printf("sssss:%sn",s); while(*p!=0) i=0; while(*p>=0&&*p<=9) datacounti = *p; i+; p+; if(i!=0) count+; p+; printf("count:%dn",count); for(i=0;i<count;i+) printf("%sn",datai);4.5#include <stdio.h>#define SIZE 4main() int dataSIZESIZE,i,j,d; int max,m=0,n=0; for(i=0;i<SIZE;i+) for(j=0;j<SIZE;j+) scanf("%d",&dataij); for(i=0;i<SI

    注意事项

    本文(华中科技大学规范标准C语言知识程序设计及应用习题集标准答案.doc)为本站会员(一***)主动上传,淘文阁 - 分享文档赚钱的网站仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知淘文阁 - 分享文档赚钱的网站(点击联系客服),我们立即给予删除!

    温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载不扣分。




    关于淘文阁 - 版权申诉 - 用户使用规则 - 积分规则 - 联系我们

    本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知淘文阁网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

    工信部备案号:黑ICP备15003705号 © 2020-2023 www.taowenge.com 淘文阁 

    收起
    展开