C语言程序设计(科学出版社)第5章 课后习题参考答案



《C语言程序设计(科学出版社)第5章 课后习题参考答案》由会员分享,可在线阅读,更多相关《C语言程序设计(科学出版社)第5章 课后习题参考答案(12页珍藏版)》请在装配图网上搜索。
1、12 《C语言程序设计》习题参考答案 第5章 习题参考答案 1 判断题 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 √ × √ × × √ × × × × × × × × × 2 填空题 (1) 32 (2) 4 (3) str1[7]= '\0'; (4) for(i=0;i<6;i++) gets(a[i]); (5) strcpy(web, ""); (6) int *p=a; (7) 5 (8) 1 (9) *(p+6)或 *(s+6) 3 选择题 1 2
2、3
4
5
6
7
8
9
10
11
12
13
14
15
BD
C
B
A
B
C
B
A
C
D
B
D
B
A
D
4 程序阅读题
(1) 6
(2) str
(3) 60
(4) bcdefga
cdefgab
defgabc
(5) a1e2
5 程序填空题
(1) # include
3、"\n")
(3) b[i]!='\0' strcpy puts(b)
(4)p=a[0]; 或p=&a[0][0]; *p
六、编程题
1、使用数组和指针2种方法来处理。
方法一(使用数组)
#include
4、-i]=t;}
for(i=0; i<10; i++)
printf("%d ",a[i]);
printf("\n");
}
方法二(使用指针)
#include 5、*q=t;}
for(p=a; p
main()
{
int i, j, t, n, a[11]={0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
for(i=0;i<10;i++)
printf("%d ", a[i]);
printf("\n");
printf("Enter the Move n=?");
scanf(" 6、%d", &n);
for(i=1; i<=n; i++)
{
t=a[10];
for(j=9;j>=0;j--) a[j+1]=a[j];
a[0]=t;
}
for(i=0; i<=10; i++)
printf("%d ", a[i]);
getch();
}
方法二(使用指针)
#include 7、 printf("%d ", *p);
printf("\n");
printf("Enter the Move n=?");
scanf("%d", &n);
for(i=1; i<=n; i++)
{
p=a+10;
t=*p;
for(;p>a;p--) *p=*(p-1);
*p=t;
}
for(p=a;p
#include 8、t a[100], b[100], i, j, p, n=0, t;
randomize();
for(i=0; i<100; i++)
{
a[i]=random(100);
if(a[i]%2==0) b[n++]=a[i];
}
for(i=0; i 9、printf("%d ", b[i]);
if(i%10==9) printf("\n");
}
getch();
}
4、
#include 10、 break;
}
}
for(i=0; i 11、ain()
{
int i;
float a[N],s=0.0,x0=0.0;
for(i=0;i 12、put score\n");
for(i=0;i 13、 a[i][M]=sum; /*求第i个学生的总成绩放到a[i][M]*/
}
max=a[0][M];
p=0;
for(i=1;i
- 温馨提示:
1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
2: 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
3.本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。