好文档就是一把金锄头!
欢迎来到金锄头文库![会员中心]
电子文档交易市场
安卓APP | ios版本
电子文档交易市场
安卓APP | ios版本

《C语言程序设计》课件chapter6answer.doc

2页
  • 卖家[上传人]:小萌新****ao
  • 文档编号:351427829
  • 上传时间:2023-05-10
  • 文档格式:DOC
  • 文档大小:64.50KB
  • / 2 举报 版权申诉 马上下载
  • 文本预览
  • 下载提示
  • 常见问题
    • 第六章 指针参考答案一、选择题(把正确选项的字母标号填到表格中)题号1234567891011121314151617181920答案CDADDBDDAAACADCBDBCC- 2 -二、判断题(错的填×,对的填√)题号1234567891011121314151617181920答案√√×√××√×√√√√××√√×√√×三、应用题1.根据要求把实现相关功能的语句填在表格中已知条件要求实现的语句int x;int a[5]={1,2,3,4,5};int *p;定义指针px并指向xint *px = &x;定义二级指针ppx并间接指向xint *ppx = &px;通过px为x输入数据的scanfscanf(“%d”,px);通过ppx输出x值的printfprintf(“%d\n”,**ppx);定义指针p1指向a[0]int *p1 = a; 或int *p1 = &a[0];定义指针p2指向a[3]int *p2 = &a[3];通过p动态分配一个存整数的空间p =(int *)malloc(sizeof(int));2.根据已知条件,把给定语句的输出结果写在表格中已知条件语句语句输出结果int a[ ]= {1,2,3,4,5};int *p = a;printf(“%d\n”,*a);1printf(“%d\n”,*&a[2]);3printf(“%d\n”,*p);1printf(“%d\n”,*(p+1));2printf(“%d\n”,*p+1);23.根据已知条件,把给定语句的输出结果写在表格中。

      已知条件语句语句输出结果int a[][3]= {1,2,3,4,5,6,7,8,9};int (*p)[3] = a;printf(“%d\n”,*p[0]);1printf(“%d\n”,*a[2]);7printf(“%d\n”,*(p[2]+1));8printf(“%d\n”,*(*p+1));2printf(“%d\n”,*(*(p+1)+2));6四、编程题1. #include "stdio.h"int main(void){ int x, *px = &x; float y, *py = &y; float **mul = &py; printf("Enter an integer: "); scanf("%d",px); printf("Enter a real number: "); scanf("%f",py); printf("%d*%.3f=",*px,*py); **mul *= *px; printf("%.2f\n",**mul); return 0;} 2. #include "stdio.h"#define N 10int main(void){ int a[N] = {1,2,3,4,5,6,7,8,9,10}; int i; int *p = a; float aver = 0; for(i=0;i

      点击阅读更多内容
      关于金锄头网 - 版权申诉 - 免责声明 - 诚邀英才 - 联系我们
      手机版 | 川公网安备 51140202000112号 | 经营许可证(蜀ICP备13022795号)
      ©2008-2016 by Sichuan Goldhoe Inc. All Rights Reserved.