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

相关文章

Vue ElementUI中Upload组件批量上传的实现代码

《VueElementUI中Upload组件批量上传的实现代码》ElementUI中Upload组件批量上传通过获取upload组件的DOM、文件、上传地址和数据,封装uploadFiles方法,使... ElementUI中Upload组件如何批量上传首先就是upload组件 <el-upl

Docker部署Jenkins持续集成(CI)工具的实现

《Docker部署Jenkins持续集成(CI)工具的实现》Jenkins是一个流行的开源自动化工具,广泛应用于持续集成(CI)和持续交付(CD)的环境中,本文介绍了使用Docker部署Jenkins... 目录前言一、准备工作二、设置变量和目录结构三、配置 docker 权限和网络四、启动 Jenkins

Python3脚本实现Excel与TXT的智能转换

《Python3脚本实现Excel与TXT的智能转换》在数据处理的日常工作中,我们经常需要将Excel中的结构化数据转换为其他格式,本文将使用Python3实现Excel与TXT的智能转换,需要的可以... 目录场景应用:为什么需要这种转换技术解析:代码实现详解核心代码展示改进点说明实战演练:从Excel到

如何使用CSS3实现波浪式图片墙

《如何使用CSS3实现波浪式图片墙》:本文主要介绍了如何使用CSS3的transform属性和动画技巧实现波浪式图片墙,通过设置图片的垂直偏移量,并使用动画使其周期性地改变位置,可以创建出动态且具有波浪效果的图片墙,同时,还强调了响应式设计的重要性,以确保图片墙在不同设备上都能良好显示,详细内容请阅读本文,希望能对你有所帮助...

CSS3 最强二维布局系统之Grid 网格布局

《CSS3最强二维布局系统之Grid网格布局》CS3的Grid网格布局是目前最强的二维布局系统,可以同时对列和行进行处理,将网页划分成一个个网格,可以任意组合不同的网格,做出各种各样的布局,本文介... 深入学习 css3 目前最强大的布局系统 Grid 网格布局Grid 网格布局的基本认识Grid 网

C# string转unicode字符的实现

《C#string转unicode字符的实现》本文主要介绍了C#string转unicode字符的实现,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随... 目录1. 获取字符串中每个字符的 Unicode 值示例代码:输出:2. 将 Unicode 值格式化

python安装whl包并解决依赖关系的实现

《python安装whl包并解决依赖关系的实现》本文主要介绍了python安装whl包并解决依赖关系的实现,文中通过图文示例介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面... 目录一、什么是whl文件?二、我们为什么需要使用whl文件来安装python库?三、我们应该去哪儿下

Python脚本实现图片文件批量命名

《Python脚本实现图片文件批量命名》这篇文章主要为大家详细介绍了一个用python第三方库pillow写的批量处理图片命名的脚本,文中的示例代码讲解详细,感兴趣的小伙伴可以了解下... 目录前言源码批量处理图片尺寸脚本源码GUI界面源码打包成.exe可执行文件前言本文介绍一个用python第三方库pi

Java中将异步调用转为同步的五种实现方法

《Java中将异步调用转为同步的五种实现方法》本文介绍了将异步调用转为同步阻塞模式的五种方法:wait/notify、ReentrantLock+Condition、Future、CountDownL... 目录异步与同步的核心区别方法一:使用wait/notify + synchronized代码示例关键

Nginx实现动态封禁IP的步骤指南

《Nginx实现动态封禁IP的步骤指南》在日常的生产环境中,网站可能会遭遇恶意请求、DDoS攻击或其他有害的访问行为,为了应对这些情况,动态封禁IP是一项十分重要的安全策略,本篇博客将介绍如何通过NG... 目录1、简述2、实现方式3、使用 fail2ban 动态封禁3.1 安装 fail2ban3.2 配