最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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

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

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

/* 足球比賽積分統(tǒng)計(jì)系統(tǒng)
? ?作者:施瑞文
? ?時(shí)間:2018.2
*/?
?//為簡(jiǎn)單化,這里沒有加上文件的操作?
#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)文章

  • C++淺析內(nèi)存分區(qū)模型概念與示例

    C++淺析內(nèi)存分區(qū)模型概念與示例

    在了解內(nèi)存分區(qū)之前,我們先來聊一聊為什么要進(jìn)行內(nèi)存分區(qū)。在進(jìn)行了內(nèi)存分區(qū)之后,在不同的區(qū)域存放的數(shù)據(jù),會(huì)有不同的生命周期,從而會(huì)讓程序員的編程變得更加靈活
    2022-09-09
  • C語言不使用strcpy函數(shù)如何實(shí)現(xiàn)字符串復(fù)制功能

    C語言不使用strcpy函數(shù)如何實(shí)現(xiàn)字符串復(fù)制功能

    這篇文章主要給大家介紹了關(guān)于C語言不使用strcpy函數(shù)如何實(shí)現(xiàn)字符串復(fù)制功能的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2021-02-02
  • 利用C語言實(shí)現(xiàn)將格式化數(shù)據(jù)和字符串相互轉(zhuǎn)換

    利用C語言實(shí)現(xiàn)將格式化數(shù)據(jù)和字符串相互轉(zhuǎn)換

    這篇文章主要為大家詳細(xì)介紹了2個(gè)函數(shù),分別是sprintf和sscanf,可以用來實(shí)現(xiàn)將格式化數(shù)據(jù)和字符串相互轉(zhuǎn)換,感興趣的小伙伴可以跟隨小編一起學(xué)習(xí)一下
    2023-03-03
  • c++入門必學(xué)庫函數(shù)sort的基本用法

    c++入門必學(xué)庫函數(shù)sort的基本用法

    Sort函數(shù)包含在頭文件為#include<algorithm>的c++標(biāo)準(zhǔn)庫中,調(diào)用標(biāo)準(zhǔn)庫里的排序方法可以不必知道其內(nèi)部是如何實(shí)現(xiàn)的,只要出現(xiàn)我們想要的結(jié)果即可,下面這篇文章主要給大家介紹了關(guān)于c++入門必學(xué)庫函數(shù)sort的基本用法,需要的朋友可以參考下
    2022-11-11
  • c語言strftime時(shí)間格式化示例

    c語言strftime時(shí)間格式化示例

    C/C++程序中需要程序顯示當(dāng)前時(shí)間,可以使用標(biāo)準(zhǔn)函數(shù)strftime,本文提供一個(gè)示例供大家參考
    2014-02-02
  • opencv3/C++實(shí)現(xiàn)光流點(diǎn)追蹤

    opencv3/C++實(shí)現(xiàn)光流點(diǎn)追蹤

    今天小編就為大家分享一篇opencv3/C++實(shí)現(xiàn)光流點(diǎn)追蹤,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
    2019-12-12
  • 雙緩沖解決VC++繪圖時(shí)屏幕閃爍

    雙緩沖解決VC++繪圖時(shí)屏幕閃爍

    相信很多人在做圖形界面開發(fā)時(shí),常常會(huì)遇到屏幕閃爍的情況,當(dāng)然我也不例外,下面我們就來詳細(xì)探討下這個(gè)問題的解決辦法
    2015-08-08
  • Qt實(shí)現(xiàn)拖拽功能圖文教程(支持拖放文件、拖放操作)

    Qt實(shí)現(xiàn)拖拽功能圖文教程(支持拖放文件、拖放操作)

    這篇文章主要給大家介紹了關(guān)于Qt實(shí)現(xiàn)拖拽功能(支持拖放文件、拖放操作)的相關(guān)資料,Qt是一款多平臺(tái)的C++應(yīng)用程序開發(fā)框架,它的獨(dú)特之處在于可以快速開發(fā)出拖放式的開發(fā)桌面程序,需要的朋友可以參考下
    2023-11-11
  • 深入學(xué)習(xí)C++中的函數(shù)概念

    深入學(xué)習(xí)C++中的函數(shù)概念

    這篇文章主要介紹了C++中的函數(shù)概念,是C++入門學(xué)習(xí)中的基礎(chǔ)知識(shí),需要的朋友可以參考下
    2015-09-09
  • C語言快速實(shí)現(xiàn)掃雷小游戲

    C語言快速實(shí)現(xiàn)掃雷小游戲

    這篇文章主要為大家詳細(xì)介紹了C語言實(shí)現(xiàn)掃雷小游戲,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2019-10-10

最新評(píng)論

确山县| 周口市| 合山市| 庆城县| 兰州市| 平昌县| 嘉善县| 北票市| 株洲市| 卓资县| 晋城| 伊宁县| 黄山市| SHOW| 焉耆| 温泉县| 兴化市| 桦南县| 南宫市| 泰兴市| 蓝田县| 沾益县| 汨罗市| 玉环县| 临城县| 龙南县| 麻城市| 锡林郭勒盟| 汤阴县| 永顺县| 米林县| 九寨沟县| 伊春市| 砚山县| 通河县| 布尔津县| 庆安县| 黄骅市| 望江县| 阳山县| 华亭县|