河南科技大学c语言课程设计选票问题实验报告

上传人:第*** 文档编号:71451107 上传时间:2019-01-20 格式:DOC 页数:12 大小:176KB
返回 下载 相关 举报
河南科技大学c语言课程设计选票问题实验报告_第1页
第1页 / 共12页
河南科技大学c语言课程设计选票问题实验报告_第2页
第2页 / 共12页
河南科技大学c语言课程设计选票问题实验报告_第3页
第3页 / 共12页
河南科技大学c语言课程设计选票问题实验报告_第4页
第4页 / 共12页
河南科技大学c语言课程设计选票问题实验报告_第5页
第5页 / 共12页
点击查看更多>>
资源描述

《河南科技大学c语言课程设计选票问题实验报告》由会员分享,可在线阅读,更多相关《河南科技大学c语言课程设计选票问题实验报告(12页珍藏版)》请在金锄头文库上搜索。

1、河南科技大学综合程序设计报告运动员信息管理系统学 院 电气工程学院 _年级专业 _学生姓名 _指导老师 _一、 题目内容和要求设计一个选票信息处理系统,从10名优秀运动员中评选出3名超级运动员。要求实现如下系统功能。(1)输入运动员信息及选票信息运动员信息包括运动员编号、姓名、运动员得分和运动员得票。运动员按1、2、3顺序编号。选票信息包括选票编号、所投运动员编号、选票有效标志。选票同样按1、2、3顺序编号。每张选票可投3个不同的运动员编号;对应位置的运动员编号可以有空缺,但必须用0表示;若编号超出规定的范围,或编号出现重复,则选票无效。从键盘或数据文件输入各运动员信息和选票信息。(2)统计运

2、动员得分选票中所列运动员顺序不同,则得分不同,选票中第1位运动员至第3位运动员所得分数依次为3分、2分、1分。根据选票信息中的运动员编号及顺序,统计运动员得分,记入相应的得分数据域;统计运动员得票数,记入相应的得票域。(3)输出运动员及选票信息输出所有运动员信息及选票信息至屏幕上。建立一个数据文件,将结构体数组中的运动员信息和选票信息写入数据文件。(4)查询运动员信息按运动员编号或姓名查询运动员信息。从键盘输入待查询运动员的编号或姓名,若找到该运动员,则输出其编号、姓名、得分及得票信息;若未找到,则输出提示信息,将查询结果输出至屏幕上。(5)查询选票信息从键盘输入待查询选票的编号,若找到该选票

3、,则输出选票信息;若未找到,则输出提示信息将查询结果输出至屏幕上。(6)评选超级运动员根据各运动员信息中的得分域,评选出得分最高的三名运动员为超级运动员。若运动员得分相同,则得票多者在前,若果得分与票数都相同,则编号小的在前。输出超级运动员排名,格式如下。 Rank Number Name Score Vote将超级运动员信息输出至屏幕上,并追加写入数据文件。(7)系统主界面。进入选票信息处理系统时,输出系统主界面。在主界面中显示系统各功能的名称及编号,用户根据需要选择执行相应的功能模块。二、 总体设计根据系统功能描述和问题分析,可将系统功能划分为若干模块,如图所示:图1三、 详细设计1、函数

4、设计图1中的各模块分别由下列若干函数实现。player_in() 运动员信息输入函数;vote_in() 选票信息输入函数;in_valid() 选票有效性判断函数;scoring() 统计选票函数;orig_to_file() 信息写入文件函数;load_mod() 信息输入模块函数;output_player() 运动员信息输出函数;output_vote() 选票信息输出函数;search_num_player() 按编号查询运动员函数;search_name_player() 按姓名查询运动员函数;search_player() 查询运动员信息函数;search_num_vote()

5、按编号查询运动员函数;super_player() 评选超级运动员函数;menu() 显示系统主界面函数;main() 选票信息处理函数。2、数据结构#define M 10#define N 30struct playerint num;char name20;int score;int votes;struct voteint num;int top3;int valid;四、 源代码#include stdio.h#include string.h#include stdlib.h#define M 5 #define N 5struct playerint num;char name2

6、0;int score; int votes; ;struct voteint num;int top3; int valid;void menu()printf(nttt the voting systemnn);printf(t* MENU *nn);printf(t 1. input player and vote 2. display all playersn);printf(t 3. display all votes 4.search playern);printf(t 5. search vote 6.display super playersn );printf(t 0. du

7、it programn);printf(nt*);void player_in(struct player plyM)int i;printf(ntplease input the information of %d players:n,M);for(i=0;iM;i+)printf(tplayer%ds number: ,i+1);scanf(%d,&plyi.num);printf(tplayer%ds name: ,i+1);scanf(%s,plyi.name);printf(tplayer%ds score: ,i+1);scanf(%d,&plyi.score);printf(tp

8、layer%ds votes:,i+1);scanf(%d,&plyi.votes);void vote_in(struct vote votN)int i;printf(ntPlease input the information of %d votes:n,N);for(i=0;iN;i+)printf(tvote%ds num: ,i+1);scanf(%d,&voti.num);printf(tfirst player number: );scanf(%d,&voti.top0);printf(tsecond player number: );scanf(%d,&voti.top1);

9、printf(tthird player number: );scanf(%d,&voti.top2);void input_inf(struct player plyM,struct vote votN)player_in(ply);vote_in(vot);int in_valid(int top3)int i,flag=1;if(top0=0&top1=0&top2=0)flag=0;else if(top0=top1&top0!=0)|(top0=top2&top0!=0)|(top1=top2&top1!=0)flag=0;elsefor(i=0;i3;i+)if(topiM)fla

10、g=0;break;return flag;void scoring(struct player plyM,struct vote votN)int i,flag,one,two,three;for(i=0;i=0)plyone.score=plyone.score+3;plyone.votes+;if(two=0) plytwo.score=plytwo.score+2;plytwo.votes+;if(three=0) plythree.score=plythree.score+1;plythree.votes+;void orig_to_file(struct player plyM,s

11、truct vote votN) int i; FILE *fp; if(fp=fopen(file2.txt,w)=NULL) printf(cannot open this filen); exit(0); fprintf(fp,ntAll players:n); fprintf(fp,tNumbertNametscoretvotesn); for(i=0;iM;i+) fprintf(fp,t%dt%st%dt%dn,plyi.num,plyi.name,plyi.score,plyi.votes); fprintf(fp,ntAll votes:n); fprintf(fp,tNumbertplayer1tplayer2tplayer3tvaildn); for(i=0;iN;i+) fprintf(fp,t%dt%dt%dt%dt%dn,voti.num,voti.top0,voti.top1,voti.top2,voti.valid); fclose(fp);void load_mod(struct player plyM,struct vote votN)input_inf(ply,vot);

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 资格认证/考试 > 自考

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号