C语言实现联赛球队管理系统_第1页
C语言实现联赛球队管理系统_第2页
C语言实现联赛球队管理系统_第3页
C语言实现联赛球队管理系统_第4页
C语言实现联赛球队管理系统_第5页
已阅读5页,还剩10页未读, 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、C语言实现联赛球队管理系统/*联赛球队管理系统*/该系统实现功能为联赛各只球队积分榜的更改、排名,可输入比赛结果,自动录入积分榜#include <stdio.h>#include <conio.h>#include <malloc.h>#include <string.h>#include <stdlib.h>#include <windows.h>#define N sizeof(struct team_information)void introduction ();/ 对本管理系统的介绍void print_tit

2、le ();/ 打印开头和星号void load_menu ();/登陆菜单void load ();/登录void post ();/ 新用户注册void print_headmenu ();/ 打印主菜单void show_league ();/ 读取联赛积分榜struct team_information *creat_league ();/ 创建联赛球队积分表total_score (int, int);/计算总积分void print_score ();void ABOUT ();/ 版权说明int exit_system ();/ 退出程序void choice1 ();/ 返回退

3、出选项void choice2 (struct team_information *);/ 增删减查选项void league (struct team_information *);/ 排序、创建积分榜void add_team ();/ 增加球队void renew ();/ 更新数据信息struct team_informationchar name20;int winning;int level;int losing;int score;int pos;struct team_information *next;void main()introduction (); print_tit

4、le ();load_menu ();void introduction ()printf ("本系统为联赛球队管理系统,显示联赛积分榜,可以输入比赛结果,直接录入积分榜。n");printf (" 积分榜中前两名升级,最后两名降级n");printf ("欢迎使用本系统!nn");void print_title ()int star;for (star=0; star<40; star+)printf ("*");printf ("n");for (star=0; star<30

5、; star+)printf ("*");printf (" 联赛球队管理系统 ");for (star=0; star<30; star+)printf ("*");void load_menu ()int number,count = 3;printf ("nn");printf ("tttt 1 登录nn");printf ("tttt 2 新用户注册nn");printf ("tttt 0 退出nn");printf ("请输入:

6、");scanf ("%d", &number);switch (number)case 1: load (); break;case 2: post (); break;case 3: exit_system (); break;void load ()FILE *fp;char name40;char password20, pass120;int m=0, n=0, count=0, i=3;while (1)printf ("nn用户名: ");scanf ("%s", name);fp=fopen (nam

7、e, "rt");if (fp = NULL)if (i-1) = 0)printf ("nn用户名不存在!程序将退出!");Sleep (1000);exit_system ();elseprintf ("nn用户名不存在! (还有%d次机会!)", i-1);i-;if (fp != NULL) break;fscanf (fp, "%s", pass1);while (1)printf ("nn密码: ");m=0;passwordm = getch ();while (passwordm

8、 != 13)printf ("*");m+;n+;passwordm = getch ();passwordm = '0'if (strcmp (pass1, password) = 0)printf ("nntttt恭喜你!登录成功!nn");Sleep (1000);system ("cls");print_headmenu ();if (strcmp (pass1, password) != 0)count +;if (count = 3)printf ("nn密码错误!程序将自动退出!n"

9、);exit_system ();printf ("nn密码错误!(还有%d次机会!)", 3-count);strcpy (password, "0");void post ()FILE *fp;char newname40, password20, pass120;int i=0, n=0;printf ("nnttt*欢迎您的加入注册!*nn");printf ("请输入注册信息: nn");printf ("tt用户名: ");scanf ("%s", newname

10、);printf ("tt密码: ");passwordi = getch();while (passwordi != 13)printf ("*");i+;n+;passwordi = getch();fp = fopen (newname, "wt");fprintf (fp, "%s", password);fclose (fp);fp = fopen (newname, "rt");while (fscanf (fp, "%s", pass1) != EOF)prin

11、tf ("nntttt恭喜您!注册成功!nn");printf ("ttn系统将自动退出,请重新登录!nn");Sleep (1000);system ("cls");load ();void change_password ()FILE *fp;char pass20, passnew20, password20, name40;int i=3, n=0, m=0, p=0, q=0, count=0;printf ("n用户名: ");scanf ("%s", name);fp=fopen

12、(name, "rt");while (fp = NULL)if (i-1) = 0)printf ("nn用户名不存在!程序将退出!");Sleep (1000);exit_system ();elseprintf ("nn用户名不存在! (还有%d次机会!)", i-1);i-;printf ("tnn原密码: ");passm = getch();while (passm != 13)printf ("*");m+;n+;passm = getch();passm = '0'

13、;fp = fopen (name, "r");fscanf (fp, "%s", password);if (strcmp (password, pass) = 0)printf ("nntn新密码: ");passnewp = getch();while (passnewp != 13)printf ("*");p+;q+;passnewp = getch();passnewp = '0'fclose (fp);fp = fopen (name, "wt");fprintf

14、(fp, "%s", passnew);fclose (fp);printf ("nntttt修改成功!nn");Sleep (1000);system ("cls");choice1 ();else printf ("nnttt密码错误!nn");Sleep (1000);system ("cls");print_headmenu ();void print_headmenu ()int number;printf ("nntt*主菜单*nn");printf ("

15、;tttt1 显示积分榜 nn");printf ("tttt2 增加球队 nn");printf ("tttt3 更新数据 nn");printf ("tttt4 修改密码 nn");printf ("tttt5 关于 nn");printf ("tttt0 退出 nn");printf ("nnn请输入: ");scanf ("%d", &number);printf ("nn");switch (number)

16、case 1: show_league (); break;case 2: add_team (); break;case 3: renew (); break;case 4: change_password (); break;case 5: ABOUT (); break;case 0: exit_system (); break;default: printf ("nn输入有误,请重新输入!"); system ("cls"); print_headmenu ();void show_league ()FILE *fp;char ans;struc

17、t team_information *head, *p1,*p2;fp=fopen ("leagueteam system.txt", "r");if (fp = NULL)printf ("未发现积分榜信息,是否输入球队信息创建积分榜?是(Y)否(N)");ans = getch ();if (ans = 'y' | ans = 'Y') head=creat_league ();else printf ("nn");choice1 ();elsehead=p2=(struct

18、team_information *)malloc(N);p1 = (struct team_information *)malloc(N);while (fscanf (fp, "%s %d %d %d %dn", p1->name, &p1->winning, &p1->level, &p1->losing, &p1->score)!=EOF)p2->next=p1;p2 = p1;p1 = (struct team_information *)malloc(N);p2->next = NULL;

19、printf ("已正确载入!nn");printf ("积分表为:(球队名称 胜 平 负 积分) nn");for (p1=head->next; p1!=NULL; p1=p1->next)printf ("%s %d %d %d %dn", p1->name, p1->winning, p1->level, p1->losing, p1->score);fclose (fp);printf ("n按任意键继续!n");getch ();printf ("nn

20、请选择您要进行的操作: nn");system ("cls");choice2 (head);struct team_information *creat_league ()struct team_information *p1,*p2,*head,*p,*team;FILE *fp;head=p2=(struct team_information *)malloc(N);printf ("nn请输入球队名称、胜场数、平场数、负场数(输入 end 0 0 0 结束)nn");p1=(struct team_information *)mallo

21、c(N);scanf ("%s %d %d %d", p1->name, &p1->winning, &p1->level, &p1->losing);p1->score = p1->winning*3 + p1->level;while (strcmp (p1->name, "end")!=0)p2->next = p1;p2 = p1;p1 = (struct team_information *) malloc (N);scanf ("%s %d %d %d&q

22、uot;, p1->name, &p1->winning, &p1->level, &p1->losing);p1->score = p1->winning*3 + p1->level;p2->next = NULL;printf ("n球队积分如下:(球队名称 胜 平 负 积分) n");p=head->next;while (p != NULL)printf ("%st%dt%dt%dt%dnn", p->name, p->winning, p->leve

23、l, p->losing, p->score);p = p->next;fp=fopen ("leagueteam system.txt", "w");fprintf (fp, "n积分:(球队名称 胜 平 负 积分)nn");for (team=head->next; team!=NULL; team=team->next)fprintf (fp, "%s %d %d %d %dn", team->name, team->winning, team->level,

24、team->losing,team->score);fclose(fp);printf ("nn文件已成功保存!n");return head;void ABOUT ()printf ("tttt联赛球队管理系统nn");printf ("tttt制作人: 刘嘉成nn");printf ("tttt版权所有 仿冒必究!nn");choice1 ();int exit_system ()system ("cls");printf ("tnnn谢谢使用!n");exi

25、t (1);void choice1 ()int number;Sleep (1000);system ("cls");printf ("1 返回nn");printf ("0 退出nn");printf ("请输入: ");scanf ("%d", &number);printf ("nn");if (number = 1)system ("cls");print_headmenu ();else exit_system ();void choi

26、ce2 (struct team_information *head)int number;printf ("nn");printf ("tttt1 积分榜nn");printf ("tttt2 增加球队nn");printf ("tttt3 更新数据nn");printf ("tttt4 其它nn"); printf ("nn请输入: ");scanf ("%d", &number);switch (number)case 1: league (

27、head); break;case 2: add_team (); break;case 3: renew (); break;case 4: printf ("nn"); choice1 (); break;void league (struct team_information *p)/链表排序FILE *fp;int number;struct team_information *head,*p2,*temp,*p1;head=p;temp=NULL;/尾结点初始化为空while(p->next->next!=temp)/外循环 使两两比较循环的次数依次减

28、小while(p->next->next!=temp)/内循环 最小数沉底 通过控制尾结点p2=p->next;if(p->next->score<p2->next->score)/交换p->next=p2->next;p2->next=p2->next->next;p->next->next=p2;p=p->next;temp=p2->next;p=head;printf ("nn积分榜如下: (球队名称 胜 负 平 积分)nn");for (p1=head->ne

29、xt; p1 != NULL; p1 = p1->next)printf ("%s %d %d %d %dn", p1->name, p1->winning, p1->level, p1->losing, p1->score);fp=fopen ("leagueteam system.txt", "w");for (p1=head->next; p1 != NULL; p1=p1->next)fprintf (fp, "%s %d %d %d %dn", p1->

30、;name, p1->winning, p1->level, p1->losing, p1->score);fclose (fp);printf ("nn文件已成功保存!nn");printf ("按任意键继续!nn");getch ();system ("cls");printf ("nn");printf ("tttt1 增加球队nn");printf ("tttt2 更新数据nn");printf ("tttt3 其它nn")

31、;scanf ("%d", &number);switch (number)case 1: add_team (); break;case 2: renew (); break;case 3: system ("cls"); choice1 (); break;void add_team ()FILE *fp;struct team_information *p;Sleep (1000);system ("cls");fp = fopen ("leagueteam system.txt", "a+

32、");p = (struct team_information *) malloc (N);printf ("n请输入要添加的球队信息: (球队名称、胜、平、负)nn");printf ("输入“end 0 0”结束输入!nn");scanf ("%s %d %d %d %d", p->name, &p->winning, &p->level, &p->losing);p->score = p->winning*3 + p->level;if (strcmp

33、(p->name, "end") = 0)choice1 ();elsefprintf (fp, "%s %d %d %d %dn", p->name, p->winning, p->level, p->losing, p->score);while (strcmp (p->name, "end") != 0)p->score = p->winning*3 + p->level;scanf ("%s %d %d %d", p->name, &

34、p->winning, &p->level, &p->losing);if (strcmp (p->name, "end") = 0)printf ("nn已成功添加! nn");choice1 ();elsefprintf (fp, "%s %d %d %d %dn", p->name, p->winning, p->level, p->losing, p->score);fclose (fp);choice1 ();void renew() /先查找后修改链表F

35、ILE *fp;char name20;struct team_information *head, *p1, *p2,*p0;fp=fopen ("leagueteam system.txt", "rt+");head=p2=(struct team_information *)malloc(N);p1 = (struct team_information *)malloc(N);while (fscanf (fp,"%s %d %d %d %dn", p1->name, &p1->winning, &p1->

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

最新文档

评论

0/150

提交评论