实验书第二部分同步习题集答案.doc

上传人:hw****26 文档编号:3550602 上传时间:2019-06-04 格式:DOC 页数:19 大小:67KB
下载 相关 举报
实验书第二部分同步习题集答案.doc_第1页
第1页 / 共19页
实验书第二部分同步习题集答案.doc_第2页
第2页 / 共19页
实验书第二部分同步习题集答案.doc_第3页
第3页 / 共19页
实验书第二部分同步习题集答案.doc_第4页
第4页 / 共19页
实验书第二部分同步习题集答案.doc_第5页
第5页 / 共19页
点击查看更多>>
资源描述

1、P115 第 7 章 数组参考答案四、编程题1. 参考程序:#includemain()float a30,sum=0,ave;int n=0,i,k=0;printf(“please input score:“);for(i=0;iave)k+;printf(“renshuwei:%dn“,k);2.数组逆序排列参考程序:#include #define N 10main( ) int aN, temp, i;for (i = 0 ; i #define N 10main( )int aNN;int i, j;for (i = 0 ; i int prime(int x)int i;int

2、flag=1;for(i=2;ilong fun(char str);main()char datastring10;long data;printf(“Please input data string:“);scanf(“%s“, datastring);data=fun(datastring);printf(“output number:“);printf(“%ldn“, data); long fun(char str)int i;long data;data=0;for(i=0;stri!=0;i+)data=data*10+(stri-0);return data;P140 第九章

3、编译预处理参考答案P142 第十章 指针参考答案四、编程题1. void swap(int *p1,int *p2)int temp;temp=*p1;*p1=*p2;*p2=temp;main()int a,b,*p1=sacnf(“%d%d”,p1,p2);swap(p1,p2)printf(“%d,%d”,a,b);2.main()float he(float ,float);float cha(float ,float);float ji(float ,float);float shang(float ,float);void process(float ,float ,float (

4、 *fun)(float ,float);float a,b;scanf(“%f,%f”,printf(“he=”);process(a,b,he);printf(“cha=”);process(a,b,cha);printf(“ji=”);process(a,b,ji);printf(“shang=”);process(a,b,shang); float he(float x,float y)return (x+y);float cha(float x,float y)return (x-y);float ji(float x,float y)return (x*y);float shang

5、(float x,float y)return (x/y);void process(float x,float y,float (*fun)(float ,float)float result;result=(*fun)(x,y);printf(“%fn”,result);3. int fun(char *p)char *f;f=p;while(*p!=0)p+;return p-f;main()char s100,*p;scanf(“%s“,s);p=s;printf(“%dn“,fun(p);P153 第 11 章 结构体与共用体参考答案四、编程题1. 参考程序:#include #de

6、fine N 5struct studentlong num;char name20;float score3;void input(struct student w, int n);void output(struct student w, int n);main()struct student stN;int n;printf(“Please input the number of worker(10):“);scanf(“%d“, input(st, n);output(st, n);void input(struct student w, int n)int i, j;float temp;for(i=0;in;i+)printf(“Please input NO %dn“, i+1);printf(“Num:“); scanf(“%ld“,getchar();printf(“name:“); gets(wi.name);for (j=0; j 3; j+) printf(“Score%d=”, j);scanf(“%f“,wi.scorej = temp;void output(struct student w, int n)int i, j;for(i=0;in;i+)

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 实用文档资料库 > 策划方案

Copyright © 2018-2021 Wenke99.com All rights reserved

工信部备案号浙ICP备20026746号-2  

公安局备案号:浙公网安备33038302330469号

本站为C2C交文档易平台,即用户上传的文档直接卖给下载用户,本站只是网络服务中间平台,所有原创文档下载所得归上传人所有,若您发现上传作品侵犯了您的权利,请立刻联系网站客服并提供证据,平台将在3个工作日内予以改正。