c语言第八章课后题答案
一、第八章习题8(p222-p228),8.1-8.3全做,8.4-8.12中选做四道,8.13-8.19中选做三道,要求给出所选择题目的程序及执行结果。
8-1(1)、
#include stdio.h
void Func(int x)
{
x=20;
}
int main()
{
int x=10;
Func(x);
printf(%d,x);
return 0;
}
结果:
分析:调用函数时只发生值的传递,形参与实参之间再也没有关系,子函数一旦退出,内部变量就释放空间
(2)
#include stdio.h
void Func(int b[])
{
int j;
for(j=0; j4; j++)
{
b[j]=j;
}
}
int main()
{
static int a[] = {5,6,7,8},i;
Func(a);
for(i=0; i4; i++)
{
printf(%d,a[i]);
}
return 0;
}
结果:
分析:数组传递时向函数传递的是数组的地址值,实参与形参共享空间,在被调函数中对数组进行修改就会造成主函数中的数组也被修改。
8.2(1)
int PositiveNum(int a[],int n)
{
int i,count=0;
for(i=0; in; i++)
{
if(a[
您可能关注的文档
最近下载
- 湖北方言调查报告PDF.pptx VIP
- 人脸识别照片拍摄标准.docx VIP
- 变频器技术考试题及答案.docx VIP
- 重症患者的肠内营养护理.pptx VIP
- 输液泵操作评分标准.doc VIP
- 青少年焦虑症护理查房.pptx VIP
- 试析《三国演义》在日本动漫中的传播与接受.pdf VIP
- 从吉川英治《三国志》看《三国演义》在日本的传播与接受The Spread and Reception of the Romance of the “Three Kingdoms” in Japan from the “Three Kingdoms” by Yoshikawa Eiji-来源:现代语言学(第2022002期)-汉斯出版社.pdf VIP
- 与总承包单位协调配合措施方案.docx VIP
- 《清静经》全文及译文.pdf VIP
原创力文档

文档评论(0)