c语言实现足球比赛积分统计系统

2024-01-12 01:50

本文主要是介绍c语言实现足球比赛积分统计系统,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

/* 足球比赛积分统计系统作者:施瑞文时间:2018.2
*/ //为简单化,这里没有加上文件的操作 
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include<windows.h>
#include<conio.h>
#define LEN sizeof(match)
typedef struct football
{char name[20];//[足球]队名int num[4];//num[0]为单支球队需比赛场数, num[1]为赢场数,num[2]为平场数,num[3]为负场数int goal;//进球数int lose;//失球数int integral;//积分int pure;//净胜球struct football *next; 
}match;
void menu();//声明菜单函数 
match *creat();//输入球队信息 
void print(match *head);//排序 
match *Add(match *head);//增加球队信息
match *Amend(match *head);//修改球队信息 
match *Del(match *head);//删除球队信息 
void End();//退出该软件 int n=0;//记录节点长度 
match *p2;void toxy(int x, int y)//将光标移动到X,Y坐标处
{COORD pos = { x , y };HANDLE Out = GetStdHandle(STD_OUTPUT_HANDLE);SetConsoleCursorPosition(Out, pos);
}void menu()
{system("cls");//清屏 system("color 72");//颜色 toxy(30,6);printf("--------------------MENU-----------------------\n");toxy(30,8);printf("|  1.   Record the information of this match  |\n");toxy(30,10);printf("|  2.   Add the information of this match     |\n");toxy(30,12);printf("|  3.   Check the information of this match   |\n");toxy(30,14);printf("|  4.   delete the information of the match   |\n");toxy(30,16);printf("|  5.   Amend the information of the match    |\n");toxy(30,18);printf("|  6.   End this operation                    |\n");toxy(30,20);printf("-----------------------------------------------\n");toxy(30,22);printf("What are you want to do ? Input please:");
}match *creat()
{system("cls");//清屏 system("color 74");//颜色 int t,n=0;match *head,*p1;p2=p1=(match *)malloc(LEN);head=NULL;/*录入足球队名,比赛场数,得、失 球数和进球积分*/ /*输入第一个节点数据 */printf("Enter the total number of the football teams:");//参赛的球队数量 scanf("%d",&t);while(n!=t){n++; printf("the name of team %d :",n);//球队名 scanf("%s",p1->name);printf("team %d win round(s):",n);//该球队赢局场数 scanf("%d",&p1->num[1]);printf("team %d draw round(s):",n);//该球队平局场数 scanf("%d",&p1->num[2]);printf("team %d goal:",n);scanf("%d",&p1->goal);printf("team %d lose:",n);scanf("%d",&p1->lose);p1->integral=p1->num[1]*2+p1->num[2];p1->pure=p1->goal-p1->lose;if(n==1){head=p1;}else{p2->next=p1;p2=p1;}p1=(match *)malloc(LEN);}p2->next=NULL;return head;
}match *Add(match *head)//增加球队 
{system("cls");//清屏 system("color 72");//颜色 match *p,*q,*newhead;int x,y=0;newhead=NULL;p=q=(match *)malloc(LEN);printf("How many teams you want to add?Input please:");scanf("%d",&x);while(y!=x){y++;printf("the name of team %d :",y);//球队名 scanf("%s",p->name);printf("team %d win round(s):",y);//该球队赢局场数 scanf("%d",&p->num[1]);printf("team %d draw round(s):",y);//该球队平局场数 scanf("%d",&p->num[2]);printf("the number of team %d goal:",y);scanf("%d",&p->goal);printf("the number of team %d lose:",y);scanf("%d",&p->lose);p->integral=p->num[1]*2+p->num[2];p->pure=p->goal-p->lose;if(y==1){newhead=p;}else{q->next=p;q=p;}p=(match *)malloc(LEN);}q->next=NULL;p2->next=newhead;//让新增加的信息接入原有链表的后面 return head;
} match *Amend(match *head)//修改信息 
{system("cls");system("color 72");do{match *p=head;char name[10];printf("Please input the team's name which you want to modify:");gets(name);while(p!=NULL&&strcmp(p->name,name)!=0){p=p->next;}if(p!=NULL){toxy(25,4); printf("team_name    win      draw      goal     lose     integral\n");toxy(25,6);printf("|%3s%10d%10d%10d%10d%10d|\n",p->name,p->num[1],p->num[2],p->goal,p->lose,p->integral);printf("Enter the new information please;\n");printf("the name of new team :");//球队名 scanf("%s",p->name);printf("team win round(s):");//该球队赢局场数 scanf("%d",&p->num[1]);printf("team  draw round(s):");//该球队平局场数 scanf("%d",&p->num[2]);printf("the number of new team's goal:");scanf("%d",&p->goal);printf("the number of  new team's lose:");scanf("%d",&p->lose);p->integral=p->num[1]*2+p->num[2];p->pure=p->goal-p->lose;break;}else{printf("Input error!Please input again:");}}while(1);return head;
}match *Del(match *head)//删除信息 
{system("cls");//清屏 do{match *p=head,*pre=NULL;//pre是p的前驱结点 char name[10];printf("Please input the team's name which you want to delete;");gets(name);while(p!=NULL&&strcmp(p->name,name)!=0){pre=p;p=p->next;}if(p!=NULL){if(pre==NULL){head=p->next;}else{pre->next=p->next;}	free(p);break;}else{printf("Input error!Please input again:");}}while(1);return head;
}void End()
{system("cls");system("color 74");toxy(20,10);printf("Thanks for your using!^-^");exit(0);//退出 getch();
}void print(match *head)
{system("cls");system("color 74");match *p,*q,t1,t2,t3,*pt;for(p=head;p!=NULL;p=p->next)//球队排序,冒泡法排序 ,关于链表的排序有点小复杂哦~ {for(q=p->next;q!=NULL;q=q->next)     //这里有3重排序 {if(p->integral<q->integral){t1=*p;*p=*q;*q=t1;	pt=p->next;p->next=q->next;q->next=pt;}else if(p->integral==q->integral){if(p->pure<q->pure){t2=*p;*p=*q;*q=t2;pt=p->next;p->next=q->next;q->next=pt;}else if(p->pure==q->pure){if(p->goal<q->goal){t3=*p;*p=*q;*q=t3;pt=p->next;p->next=q->next;q->next=pt;}}}}}p=head;//重新让p指向第一个结点 toxy(20,4);printf("--------------------the football match imformation----------------------\n");toxy(20,6);printf("team_name    win      draw      goal     lose     integral\n");int m=8;while(p!=NULL){toxy(20,m);printf("|%3s%10d%10d%10d%10d%10d|\n",p->name,p->num[1],p->num[2],p->goal,p->lose,p->integral);p=p->next;m+=2;}printf("\nPlease press any key return to MENU. ");getch();}int main()
{match *head;char x;do{system("cls");system("color 72");menu();x=getch();switch(x){case '1':head=creat();break;case '2':head=Add(head);break;case '3':print(head);break;case '4':head=Del(head);break;case '5':head=Amend(head);break;case '6':End();break;default:printf("Input error!Please input again:");	}}while(1);//永远为真 return 0;
}

这篇关于c语言实现足球比赛积分统计系统的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/596413

相关文章

mybatis执行insert返回id实现详解

《mybatis执行insert返回id实现详解》MyBatis插入操作默认返回受影响行数,需通过useGeneratedKeys+keyProperty或selectKey获取主键ID,确保主键为自... 目录 两种方式获取自增 ID:1. ​​useGeneratedKeys+keyProperty(推

Spring Boot集成Druid实现数据源管理与监控的详细步骤

《SpringBoot集成Druid实现数据源管理与监控的详细步骤》本文介绍如何在SpringBoot项目中集成Druid数据库连接池,包括环境搭建、Maven依赖配置、SpringBoot配置文件... 目录1. 引言1.1 环境准备1.2 Druid介绍2. 配置Druid连接池3. 查看Druid监控

Linux在线解压jar包的实现方式

《Linux在线解压jar包的实现方式》:本文主要介绍Linux在线解压jar包的实现方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录linux在线解压jar包解压 jar包的步骤总结Linux在线解压jar包在 Centos 中解压 jar 包可以使用 u

Linux系统性能检测命令详解

《Linux系统性能检测命令详解》本文介绍了Linux系统常用的监控命令(如top、vmstat、iostat、htop等)及其参数功能,涵盖进程状态、内存使用、磁盘I/O、系统负载等多维度资源监控,... 目录toppsuptimevmstatIOStatiotopslabtophtopdstatnmon

c++ 类成员变量默认初始值的实现

《c++类成员变量默认初始值的实现》本文主要介绍了c++类成员变量默认初始值,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧... 目录C++类成员变量初始化c++类的变量的初始化在C++中,如果使用类成员变量时未给定其初始值,那么它将被

Qt使用QSqlDatabase连接MySQL实现增删改查功能

《Qt使用QSqlDatabase连接MySQL实现增删改查功能》这篇文章主要为大家详细介绍了Qt如何使用QSqlDatabase连接MySQL实现增删改查功能,文中的示例代码讲解详细,感兴趣的小伙伴... 目录一、创建数据表二、连接mysql数据库三、封装成一个完整的轻量级 ORM 风格类3.1 表结构

基于Python实现一个图片拆分工具

《基于Python实现一个图片拆分工具》这篇文章主要为大家详细介绍了如何基于Python实现一个图片拆分工具,可以根据需要的行数和列数进行拆分,感兴趣的小伙伴可以跟随小编一起学习一下... 简单介绍先自己选择输入的图片,默认是输出到项目文件夹中,可以自己选择其他的文件夹,选择需要拆分的行数和列数,可以通过

Python中将嵌套列表扁平化的多种实现方法

《Python中将嵌套列表扁平化的多种实现方法》在Python编程中,我们常常会遇到需要将嵌套列表(即列表中包含列表)转换为一个一维的扁平列表的需求,本文将给大家介绍了多种实现这一目标的方法,需要的朋... 目录python中将嵌套列表扁平化的方法技术背景实现步骤1. 使用嵌套列表推导式2. 使用itert

Python使用pip工具实现包自动更新的多种方法

《Python使用pip工具实现包自动更新的多种方法》本文深入探讨了使用Python的pip工具实现包自动更新的各种方法和技术,我们将从基础概念开始,逐步介绍手动更新方法、自动化脚本编写、结合CI/C... 目录1. 背景介绍1.1 目的和范围1.2 预期读者1.3 文档结构概述1.4 术语表1.4.1 核

在Linux中改变echo输出颜色的实现方法

《在Linux中改变echo输出颜色的实现方法》在Linux系统的命令行环境下,为了使输出信息更加清晰、突出,便于用户快速识别和区分不同类型的信息,常常需要改变echo命令的输出颜色,所以本文给大家介... 目python录在linux中改变echo输出颜色的方法技术背景实现步骤使用ANSI转义码使用tpu