




已阅读5页,还剩15页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
c语言课程设计题目名称: 姓 名: 学 号:班级序号:指导老师: 目录前言 * 2设计思路及要求 * 31.程序设计思路 * 32.程序设计要求 * 3程序总体设计流程图 * 5功能模块的调试和测试 * 51.增加订户模块 * 62.删除过期订户 * 73.输出所有信息 * 84.统计本月订户 * 95.查询用户 * 10程序设计的原代码 * 11结束语 * 18前言c语言是一种计算机程序设计语言。它既有高级语言的特点,又具有汇编语言的特点。它可以作为系统设计语言,编写工作系统应用程序,也可以作为应用程序设计语言,编写不依赖计算机硬件的应用程序。c语言是一种结构化语言。它层次清晰,便于按模块化方式组织程序,易于调试和维护。c语言的表现能力和处理能力极强。它不仅具有丰富的运算符和数据类型,便于实现各类复杂的数据结构。它还可以直接访问内存的物理地址,进行位(bit)一级的操作。因此,它的应用范围广泛。c语言在很多方面都可以用,不仅仅是在软件开发上,各类科研都是需要用到c语言的。具体应用比如我是学硬件的,单片机以及嵌入式系统都可以用c来开发。c 语言发展如此迅速, 而且成为最受欢迎的语言之一,主要因为它具有强大的功能。许多著名的系统软件, 如dbase plus、dbase 都是由c 语言编写的。用c语言加上一些汇编语言子程序, 就更能显示c 语言的优势了, 像pc- dos 、wordstar等就是用这种方法编写的。在信息化迅速更新的今天,计算机已经普及,而c语言为计算机的更新换代提供了很好的基础平台,作为当代的大学生学好c语言是很重要的。为此学校为我们提供了提高c语言专业知识的载体,为我们开设了c语言上机实习课程。设计思路及要求程序设计思路c语言程序设计主要是利用c语言的设计操作能力设计出一个杂志订阅管理系统,一个完整的杂志订阅管理软件至少应该具有:(1)能够提供文件的储存、输入、输出、删除等操作;(2)能够提供文件的添加操作,增加新用户等操作;(3)能够提供文件的查询,查找等操作;(4)能够通过文件的删除操作纪实删除已到期的订户记录;(5)能够提供统计和显示操作统计本期杂志本期用户数并打印运算结果;(6)另外文件还要具备提供键盘式选择菜单以实现功能选择.程序设计要求c语言程序的设计需要明确课程设计的目的,能根据课程设计的要求,查阅相关文献,为完成设计准备必要的知识,提高学生用高级语言进行程序设计的能力,重点提高用c语言进行文件操作和绘图应用的编程技术水平,并能够初步了解软件开发的一般方法和步骤,提高撰写技术文档的能力。而对于本次程序设计的要求则是:使用计算机对一种杂志的订阅进行管理,该杂志拥有的最多用户不能超过10人,每个订户的信息包括:姓名,性别,地址,电话号码,杂志单价,订阅数,订阅的期限(至*年*月)。要求用菜单选择并完成下述功能:(1) 增加新用户,即将订户的全部信息输入的文件中;(2) 根据当天的日期对订户文件进行查询,删除已到期的订户记录:(3) 统计本期杂志订户数并打印运算结果:本期订户信息表订户名 订阅数 单价 金额李平 2 5.5 11.0黄海 1 5.5 5.5合计 3 1.0 16.5程序总体设计流程图功能模块的调试和测试1.增加订户模块 2.删除过期订户在上图中我假设当前时间为20080808对文件中订户信息进行更新。下面来看看保存有订户信息的文本文件中的数据情况。在上图中我们可以看出所有的到期时间在20080808之前的订户的信息都被一段特殊的信息所代替。3.输出所有信息在上图中我输出了在msg.txt中的所有订户的信息。4.统计本月订户上图中假设这个月是20080808。注意这个功能与删除过期订户的差异,统计功能只是输出文件中没有过期的订户,而没有在文件中将过期的订户删除,而删除过期订户在文件中将过期的订户删除。5.查询用户以上是查询姓名是xiao的订户的信息。 程序设计的原代码#include stdio.h#include string.h#include stdlib.htypedef struct msgchar name20;char sex10;char dialnumber11; int count; float price; float money; char date20;char readeraddr50;msgnode;void start()printf(*n);printf(* writen by david x.h. of cug *n);printf(* *n);printf(* *n);printf(* david x.h. all rights reserved *n);printf(*n);void textout()printf(ttwanna check message,press-0.nn); printf(ttwanna add a new reader,press-1.nn);printf(ttwanna update the message table,press-2.nn);printf(ttwanna output all the message ,press-3.nn);printf(ttwanna display readers this month. ,press-4.nn);printf(ttwanna exit,press-5.nn);int checkdatemon(char * date) char chdate3; chdate0=date5; chdate1=date6; chdate2=0; return atoi(chdate);int checkdateday(char * date)char chdate3;chdate0=date8;chdate1=date9; chdate2=0; return atoi(chdate);int addreader()file *fp; msgnode ad; if(fp=fopen(msg.txt,at)=null)printf(cannot open the file or cannot find the file.please check out .n); getch(); return 0;printf(input start. _ n); printf(please input the name: _ n); scanf(%s,);printf(please input the sexmale/female: _ n); scanf(%s,ad.sex);printf(please input the dialnumber: _ n); scanf(%s,ad.dialnumber); printf(please input the count: _ n); scanf(%d,&ad.count); printf(please input the price: _ n); scanf(%f,&ad.price); printf(please input the date: _ n); scanf(%s,ad.date); while(ad.date4!=.| ad.date7!=.| strlen(ad.date)!=10 |checkdatemon(ad.date)=13|checkdateday(ad.date)=32)printf(the format is not right or the date is not existed.n ); printf(you should input the date like this yyyy.mm.ddn);printf(please input the date again: _ n); scanf(%s,ad.date);printf(please input the address of reader: _ n); scanf(%s,ad.readeraddr); fprintf(fp,%15s %8s %13s %7d %7.2f %10.2f %13s %-50sn,,ad.sex,ad.dialnumber,ad.count,ad.price,ad.count*ad.price,ad.date,ad.readeraddr); fclose(fp); return 1;int updatemsg(char *currdate)msgnode currnode,movenode ; int i=0,j=0; file *fp; if(fp=fopen(msg.txt,rt+)=null)printf(%s n,cannot open the file or cannot find the file.please check out .); return 0;i=ftell(fp); fscanf(fp,%s%s%s%d%f%f%s%s ,,currnode.sex,currnode.dialnumber,&currnode.count,&currnode.price,&currnode.money,currnode.date,currnode.readeraddr); j=ftell(fp);j=j-i;rewind(fp);while(!feof(fp)fscanf(fp,%s%s%s%d%f%f%s%s ,,currnode.sex,currnode.dialnumber ,&currnode.count,&currnode.price,&currnode.money,currnode.date,currnode.readeraddr);if(feof(fp)break;if(strcmp(currdate,currnode.date)0) fseek(fp,-j,1); fprintf(fp,%15s %8s %13s %7d %7.2f %10.2f %13s %-50s ,null,null,null,0,0.0,0.0,9999.99.99,null); fseek(fp,2l,1); return 1;int outputall()file *fp; msgnode oa; int allcount=0; float allmoney=0; if(fp=fopen(msg.txt,rt)=null)printf(cannot open the file or cannot find the file.please check out .n); getch();return 0; printf(%15s %8s %13s %7s %7s %10s %13s %-50sn,readername ,readsex ,number ,count ,price ,moneysum ,date ,readeraddress); while(!feof(fp)fscanf(fp,%s%s%s%d%f%f%s%s,,oa.sex,oa.dialnumber,&oa.count,&oa.price,&oa.money,oa.date,oa.readeraddr);if(feof(fp)break; allcount+=oa.count; allmoney+=oa.money;if(strcmp(oa.sex,null) printf(%15s %8s %13s %7d %7.2f %10.2f %13s %-50sn,,oa.sex,oa.dialnumber,oa.count,oa.price,oa.money, oa.date,oa.readeraddr); printf(%15s %8s %13s %7d %7.2f %10.2f %13s %-50sn,heji,-,-,allcount,-,allmoney,2007.09.04,-);return 1;int checkreader(char *name)file *fp; int i,j; char ch; msgnode cr; if(fp=fopen(msg.txt,rt)=null)printf(cannot open the file or cannot find the file.please check out .);getch(); return 0;i=ftell(fp); fscanf(fp,%s%s%s%d%f%f%s%s,,cr.sex,cr.dialnumber,&cr.count,&cr.price,&cr.money,cr.date,cr.readeraddr); j=ftell(fp); rewind(fp); j=j-i;while(!feof(fp)fscanf(fp,%s%s%s%d%f%f%s%s,,cr.sex,cr.dialnumber,&cr.count,&cr.price,&cr.money,cr.date,cr.readeraddr); i=ftell(fp);if(!strcmp(,name)printf(the reader you are checking is existed in the list.n);fseek(fp,-j,1); fscanf(fp,%s%s%s%d%f%f%s%s ,,cr.sex,cr.dialnumber,&cr.count ,&cr.price,&cr.money,cr.date,cr.readeraddr);if(feof(fp)break; printf(%15s %8s %13s %7d %7f %10f %13s %-50sn ,,cr.sex,cr.dialnumber,cr.count ,cr.price,cr.money,cr.date,cr.readeraddr);return 1;int displayreader(char *date)file *fp; int i,j; msgnode cr; if(fp=fopen(msg.txt,rt)=null)printf(cannot open the file or cannot find the file.please check out .);getch(); return 0;while(!feof(fp)fscanf(fp,%s%s%s%d%f%f%s%s,,cr.sex,cr.dialnumber,&cr.count,&cr.price,&cr.money,cr.date,cr.readeraddr);if(feof(fp)break;if(!strcmp(9999.99.99,cr.date)continue;if(strcmp(date,cr.date)0 ) printf(%15s %8s %13s %7d %7f %10f %13s %-50sn ,,cr.sex,cr.dialnumber,cr.count ,cr.price,cr.money,cr.date,cr.readeraddr);return 1;main() char str30;int ch;start();textout();scanf(%d,&ch);while(ch!=5)if(ch=0)printf(please input the name you wanna index: _n);scanf(%s,str);if(checkreader(str)printf(you have successfully index the reader!n); textout();scanf(%d,&ch);continue ; if(ch=1)if(addreader()printf(you have successfully add a reader!n);textout();scanf(%d,&ch);continue ;if(ch=2)printf(please input the current date: _n);scanf(%s,str); if(updatemsg(str)printf(y
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 绿色供应链管理在制造业中的绿色供应链人才培养与引进策略报告
- 单位安全施工方案(3篇)
- 2025年氨咖黄敏胶囊行业研究报告及未来行业发展趋势预测
- 衡益中学入学考试题目及答案
- 印刷厂工人实操考试题及答案
- 湖南省邵阳市2026届英语九上期末检测试题含解析
- 2026届安徽省合肥市瑶海区英语九上期末质量检测模拟试题含解析
- 科技素养考试题目及答案
- 2025年物流供应链管理试题及答案解析
- 2026届山东省淄博市博山区九年级化学第一学期期中考试试题含解析
- 劳动课种植教学方案
- 2024年全国职业院校技能大赛高职组(环境检测与监测赛项)考试题库(含答案)
- 实验-大肠杆菌感受态细胞的制备及转化
- 2025年中考语文阅读复习:理解词语含义(含练习题及答案)
- GB/T 44421-2024矫形器配置服务规范
- 磷酸哌嗪宝塔糖的毒理学研究
- 【课件】2025届高三生物一轮复习备考策略研讨
- 灵芝培训课件
- 环形开挖预留核心土法
- 妇科医生进修汇报课件
- 《科室管理方案》课件
评论
0/150
提交评论