c语言程序设计华中科技大学课后答案,华中科技大学标准C语言程序设计及应用习题答案.doc...

62e50291a81fc54b507f33cb80033297.gif 华中科技大学标准C语言程序设计及应用习题答案.doc

(32页)

a9ce469fcdbfa7484c192b9de0437da5.gif

本资源提供全文预览,点击全文预览即可全文预览,如果喜欢文档就下载吧,查找使用更方便哦!

29.9 积分

第二章一.选择题1.C 2.B D 3.A 4.A 5. D C 6.C 7.D 8.B 9.A 10.D11.B 12.D 13.C 14.D 15.A16.B 17.A 18.B 二.判断题1.错2.错3.错4.错三.填空题1. B 662. n1=%d\nn2=%d\n3. 0四.计算1(1) x|y = 0x002f(2) x^y = 0x0026(3) x&y = 0x0009;(4) ~x+~y = 0xffc6(5) x<>=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 %d\n",(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 %d\n",max);}2.3main(){ int i=0,sum=0; while(i<=100) { sum+=i; i++; } printf("1+2+3+......+100=%d\n",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 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:%8d\n",a,b); } printf("The Sum Of Is:%d\n",sum);}2.7#include 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=%f\n",y);}2.8#include main(){ long a,i,b,a1; while(1) { printf("please input data(1-99999):"); scanf("%ld",&a); printf("a:%ld\n",a); if(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:%ld\n",i,a1); }}2.9#include #include #include main(){ int a,b,i,k=0; randomize(); a=random(1001);/*create a random data(0-1000)*/ for(i=0;ib) { k++; printf("\n%d:Smaller,guess again!\n",k); } else if(ax) max = y; for(i=max;i<=x*y;i++) { if((i%x==0)&&(i%y==0)) { gbs = i; break; } } return gbs;}7.4.4#include #include void Delete_Ch(char *,char);main(){ char str[80],ch; printf("please a string:"); gets(str); printf("please a char:"); scanf("%c",&ch); Delete_Ch(str,ch); printf("%s\n\n",str);}void Delete_Ch(char *p,char ch){ while(*p) { if(*p==ch) { strcpy(p,p+1); } else p++; }}7.4.5#include int Is_ShuShu(int); /* return 0:shushu return -1:no shushu*/main(){ int a,ret; printf("pls enter a integer:"); scanf("%d",&a); ret = Is_ShuShu(a); if(ret==0) printf("%d is a shushu!!!\n",a); else printf("%d is not a shushu\n",a);}int Is_ShuShu(int x){ int i; for(i=2;i=x/2) return 0;}7.4.6#include #include void StrCat(char *s1,char *s2){ while(*s1!='\0') s1++; while(*s2!='\0') { *s1 = *s2; s1++; s2++; } *s1='\0';}main(){ char a[200]="123456789",b[100]="ABCDEFG"; printf("pls enter string 1:"); gets(a); printf("pls enter string 2:"); gets(b); StrCat(a,b); printf("%s\n\n",a);}7.4.7#include #include void Stat(char *s,int *ch,int *dig,int *spa,int *oth){ while(*s!='\0') { if(((*s>='a')&&(*s='A')&&(*s='0')&&(*s<='9')) (*dig)++; else if(*s == ' ') (*spa)++; else (*oth)++; s++; }}main(){ char a[200]; int ch=0,dig=0,spa=0,oth=0; printf("pls enter a string :"); gets(a); Stat(a,&ch,&dig,&spa,&oth); printf("ch:%d dig:%d spa:%d oth:%d",ch,dig,spa,oth);}7.4.8#include #include void reverse(char *s){ if(*s){}main(){ char s[] = "abcde"; reverse(s); puts(s);}7.4.9#include #include paixu(int *p,int n,int flag){ int i,j,m; int temp; for(i=0;i

524d6daf746efaa52c3c71bbfe7ba172.gif  天天文库所有资源均是用户自行上传分享,仅供网友学习交流,未经上传用户书面授权,请勿作他用。

关于本文

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值