欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

c語(yǔ)言實(shí)現(xiàn)足球比賽積分統(tǒng)計(jì)系統(tǒng)

 更新時(shí)間:2022年05月30日 10:18:52   作者:Sriven  
這篇文章主要為大家詳細(xì)介紹了c語(yǔ)言實(shí)現(xiàn)足球比賽積分統(tǒng)計(jì)系統(tǒng),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了c語(yǔ)言實(shí)現(xiàn)足球比賽積分統(tǒng)計(jì)系統(tǒng)的具體代碼,供大家參考,具體內(nèi)容如下

/* 足球比賽積分統(tǒng)計(jì)系統(tǒng)
? ?作者:施瑞文
? ?時(shí)間:2018.2
*/?
?//為簡(jiǎn)單化,這里沒(méi)有加上文件的操作?
#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];//[足球]隊(duì)名
?? ?int num[4];//num[0]為單支球隊(duì)需比賽場(chǎng)數(shù), num[1]為贏場(chǎng)數(shù),num[2]為平場(chǎng)數(shù),num[3]為負(fù)場(chǎng)數(shù)
?? ?int goal;//進(jìn)球數(shù)
?? ?int lose;//失球數(shù)
?? ?int integral;//積分
?? ?int pure;//凈勝球
?? ?struct football *next;?
}match;
void menu();//聲明菜單函數(shù)?
match *creat();//輸入球隊(duì)信息?
void print(match *head);//排序?
match *Add(match *head);//增加球隊(duì)信息
match *Amend(match *head);//修改球隊(duì)信息?
match *Del(match *head);//刪除球隊(duì)信息?
void End();//退出該軟件?
?
int n=0;//記錄節(jié)點(diǎn)長(zhǎng)度?
match *p2;
?
void toxy(int x, int y)//將光標(biāo)移動(dòng)到X,Y坐標(biāo)處
{
? 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;
?? ?
?? ?/*錄入足球隊(duì)名,比賽場(chǎng)數(shù),得、失 球數(shù)和進(jìn)球積分*/?
?? ?
?? ?/*輸入第一個(gè)節(jié)點(diǎn)數(shù)據(jù) */
?
?? ?printf("Enter the total number of the football teams:");//參賽的球隊(duì)數(shù)量?
?? ?scanf("%d",&t);
?? ?
?? ?
?? ?
?? ?while(n!=t)
?? ?{
?? ??? ?n++;?
?? ??? ?printf("the name of team %d :",n);//球隊(duì)名?
?? ? ? ?scanf("%s",p1->name);
?? ?
?? ? ? ?printf("team %d win round(s):",n);//該球隊(duì)贏局場(chǎng)數(shù)?
?? ? ? ?scanf("%d",&p1->num[1]);
?? ?
?? ? ? ?printf("team %d draw round(s):",n);//該球隊(duì)平局場(chǎng)數(shù)?
?? ? ? ?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)//增加球隊(duì)?
{
?? ?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);//球隊(duì)名?
?? ? ? ?scanf("%s",p->name);
?? ?
?? ? ? ?printf("team %d win round(s):",y);//該球隊(duì)贏局場(chǎng)數(shù)?
?? ? ? ?scanf("%d",&p->num[1]);
?? ?
?? ? ? ?printf("team %d draw round(s):",y);//該球隊(duì)平局場(chǎng)數(shù)?
? ? ? ? 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 :");//球隊(duì)名?
?? ??? ? ? ?scanf("%s",p->name);
?? ??? ?
?? ??? ? ? ?printf("team win round(s):");//該球隊(duì)贏局場(chǎng)數(shù)?
?? ??? ? ? ?scanf("%d",&p->num[1]);
?? ??? ?
?? ??? ? ? ?printf("team ?draw round(s):");//該球隊(duì)平局場(chǎng)數(shù)?
?? ? ? ? ? ?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的前驅(qū)結(jié)點(diǎn)?
?? ? ? 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)//球隊(duì)排序,冒泡法排序 ,關(guān)于鏈表的排序有點(diǎn)小復(fù)雜哦~?
?? ?{
?? ??? ?
?? ??? ?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指向第一個(gè)結(jié)點(diǎn)?
?? ?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);//永遠(yuǎn)為真?
? ??
?? ?return 0;
}

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論