资源预览内容
第1页 / 共24页
第2页 / 共24页
第3页 / 共24页
第4页 / 共24页
第5页 / 共24页
第6页 / 共24页
第7页 / 共24页
第8页 / 共24页
第9页 / 共24页
第10页 / 共24页
亲,该文档总共24页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述
高级语言程序设计课程设计题目: 专 业 计算机 类 班 级 计算机类1102 学 生 学 号 指导教师 _起止时间 2012.2.132012.2.17 2012年 2月目录实验报告3必做题:3选做题:8题目10 写一个日历显示程序8流程图:(如下)14工程代码:19心得体会24不同的学习内容,预习作业也有差异。概念型内容可采用阅读理解的方法进行预习,计算型的内容可采用尝试练习的方法进行预习,空间图形内容可采用实验操作的方法进行预习。of rural drinking water sources, protection of drinking water sources in rural areas by the end of the delimitation of the scope of protection, complete with warning signs, isolating network protection facilities实验报告必做题: (1) 编一程序对2种排序方法进行比较:交换法、选择法、插入法、冒泡法四种方法选2。具体比较方法是随机生成一组(300个)的100以内的整数数据,用选定的2种排序方法进行排序。纪录排序过程中数据比较和交换的次数,输出比较结果。#include#includeint main(void) int a300,b300; int i,j,temp,t; int s=0,p=0,s1=0,p1=0; for(i=0;i300;i+) ai=rand()%100; bi =ai; for(i=0;i299;i+) for(j=i+1;j300;j+) if(aiaj) temp=ai; ai=aj; aj=temp; s+; p+; printf(%d %dn,s,p);printf(n); for(i=0;i299;i+) t=i; for(j=i+1;j300;j+) if(btbj) t=j; if(t!=i) temp=bi; bi=bt; bt=temp; s1+; p1+; printf(%d %dn,s1,p1); return 0;运行结果:在这个题目中选择了交换法和选择法,首先要产生300个随机数,其次要懂得两种排序法的原理,然后进行编程,同时利用循环结构。关键在于产生随机数和排序。通过比较发现交换法的交换次数比选择法少,比较的次数两者一样。(2) 写一个函数void maxMinAver(int *data, int *max, int *min,float * ave,int size), 求一组数据的最大值、最小值和平均值,测试之。其中data指向给定数据的数组的指针,max、min、ave分别指向最大值、最小值和平均值,size是数组的大小。要求第一个实参是数组,第2、3、4个实参都是对普通的简单变量的某种操作,最后一个实参是数组的大小。测试之#includevoid maxMinAver(int *data, int *max, int *min,float * ave,int size);int main(void) int *data,*max,*min,size; float *ave; maxMinAver(data,max,min,ave,size); return 0;void maxMinAver(int *data, int *max, int *min,float * ave,int size) int a10; int b,c,n,j,s=0,temp; float d; data=a; max=&b; min=&c; ave=&d; for(n=0;n10;n+) scanf(%d,&an); /交换法排序求最大最小值 for(n=0;n9;n+) for(j=n+1;j10;j+) if(anaj) temp=an; an=aj; aj=temp; b=a0; c=a9;/求平均数 for(n=0;n10;n+) s=s+an; d=(float)s/10; printf(%d %d %f,*max,*min,*ave);这个题目需要利用函数调用,还要利用指针的间接引用法,设计函数将最大、最小以及平均值求出来。关键是函数调用。选做题:题目10 写一个日历显示程序 基本功能: 1)输入任一年将显示出该年的所有月份日期,对应的星期 2) 注意闰年情况其显示格式要求如下:1)月份:中文英文都可以,2)下一行显示星期,从周日到周六,中英文都可以3)下一行开始显示日期从1号开始,并按其是周几实际情况与上面的星期数垂直对齐当输入2004显示如下:Input the year:2004Input the file name:aThe calendar of the year 2004. Januray 1 February 2 Sun Mon Tue Wed Thu Fri Sat Sun Mon Tue Wed Thu Fri Sat 1 2 3 1 2 3 4 5 6 7 4 5 6 7 8 9 10 8 9 10 11 12 13 14 11 12 13 14 15 16 17 15 16 17 18 19 20 21 18 19 20 21 22 23 24 22 23 24 25 26 27 28 25 26 27 28 29 30 31 29 = = March 3 April 4 Sun Mon Tue Wed Thu Fri Sat Sun Mon Tue Wed Thu Fri Sat 1 2 3 4 5 6 1 2 3 7 8 9 10 11 12 13 4 5 6 7 8 9 10 14 15 16 17 18 19 20 11 12 13 14 15 16 17 21 22 23 24 25 26 27 18 19 20 21 22 23 24 28 29 30 31 25 26 27 28 29 30 = =#includeint year(int p);int riqi(int z);int xinqi(int w,int l,int jj);void dayin(int m,int n,int a12,int b12,char c30);int main(void) int n,s; int m,qq,xx; printf(Input the year:); scanf(%d,&n); s=year(n); int a12 = 1,2,3,4,5,6,7,8,9,10,11,12; int b12=31,s,31,30,31,30,31,31,30,31,30,31; /printf(%d,b1); char c=sun mon tue wed thr fri sat; printf(The calendar of the year %dn,n); m=riqi(n); /printf(%dn,m); dayin(m,n,a,b,c);return 0;/判断输入的那一年是否是闰年int year(int p) if(p%4 != 0)return 28;if(p%4 = 0)if(p%100 = 0)if(p%400 = 0)return 29;return 28;return 29;/求输入那一年的1月1日式星期几/*参照1997年1月1日*/int riqi(int z)int d;int days=(z-1997)*365;int i = (z- 1997)/4;days=days+i*1;/*1997年1月1日是星期三*/d=days%7+1;d=(d+2)%7;if(d = 0)d = 7;
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号