#include <malloc.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #define NULL 0 #define MaxSize 30 typedef struct athletestruct /*運動員*/ { char name[20]; int score; /*分?jǐn)?shù)*/ int range; /**/ int item; /*項目*/ }ATH; typedef struct schoolstruct /*學(xué)校*/ { int count; /*編號*/ int serial; /**/ int menscore; /*男選手分?jǐn)?shù)*/ int womenscore; /*女選手分?jǐn)?shù)*/ int totalscore; /*總分*/ ATH athlete[MaxSize]; /**/ struct schoolstruct *next; }SCH; int nsc,msp,wsp; int ntsp; int i,j; int overgame; int serial,range; int n; SCH *head,*pfirst,*psecond; int *phead=NULL,*pafirst=NULL,*pasecond=NULL; void create(); void input () { char answer; head = (SCH *)malloc(sizeof(SCH)); /**/ head->next = NULL; pfirst = head; answer = 'y'; while ( answer == 'y' ) { Is_Game_DoMain: printf("\nGET Top 5 when odd\nGET Top 3 when even"); printf("\n輸入運動項目序號 (x<=%d):",ntsp); scanf("%d",pafirst); overgame = *pafirst; if ( pafirst != phead ) { for ( pasecond = phead ; pasecond < pafirst ; pasecond ++ ) { if ( overgame == *pasecond ) { printf("\n這個項目已經(jīng)存在請選擇其他的數(shù)字\n"); goto Is_Game_DoMain; } } } pafirst = pafirst + 1; if ( overgame > ntsp ) { printf("\n項目不存在"); printf("\n請重新輸入"); goto Is_Game_DoMain; } switch ( overgame%2 ) { case 0: n = 3;break; case 1: n = 5;break; } for ( i = 1 ; i <= n ; i++ ) { Is_Serial_DoMain: printf("\n輸入序號 of the NO.%d (0<x<=%d): ",i,nsc); scanf("%d",&serial); if ( serial > nsc ) { printf("\n超過學(xué)校數(shù)目,請重新輸入"); goto Is_Serial_DoMain; } if ( head->next == NULL ) { create(); } psecond = head->next ; while ( psecond != NULL ) { if ( psecond->serial == serial ) { pfirst = psecond; pfirst->count = pfirst->count + 1; goto Store_Data; } else { psecond = psecond->next; } } create(); Store_Data: pfirst->athlete[pfirst->count].item = overgame; pfirst->athlete[pfirst->count].range = i; pfirst->serial = serial; printf("Input name:) : "); scanf("%s",pfirst->athlete[pfirst->count].name); } printf("\n繼續(xù)輸入運動項目(y&n)?"); answer = getchar(); printf("\n"); } } void calculate() /**/ { pfirst = head->next; while ( pfirst->next != NULL ) { for (i=1;i<=pfirst->count;i++) { if ( pfirst->athlete[i].item % 2 == 0 ) { switch (pfirst->athlete[i].range) { case 1:pfirst->athlete[i].score = 5;break; case 2:pfirst->athlete[i].score = 3;break; case 3:pfirst->athlete[i].score = 2;break; } } else { switch (pfirst->athlete[i].range) { case 1:pfirst->athlete[i].score = 7;break; case 2:pfirst->athlete[i].score = 5;break; case 3:pfirst->athlete[i].score = 3;break; case 4:pfirst->athlete[i].score = 2;break; case 5:pfirst->athlete[i].score = 1;break; } } if ( pfirst->athlete[i].item <=msp ) { pfirst->menscore = pfirst->menscore + pfirst->athlete[i].score; } else { pfirst->womenscore = pfirst->womenscore + pfirst->athlete[i].score; } } pfirst->totalscore = pfirst->menscore + pfirst->womenscore; pfirst = pfirst->next; } } void output() { pfirst = head->next; psecond = head->next; while ( pfirst->next != NULL ) { // clrscr(); printf("\n第%d號學(xué)校的結(jié)果成績:",pfirst->serial); printf("\n\n項目的數(shù)目\t學(xué)校的名字\t分?jǐn)?shù)"); for (i=1;i<=ntsp;i++) { for (j=1;j<=pfirst->count;j++) { if ( pfirst->athlete[j].item == i ) { printf("\n %d\t\t\t\t\t\t%s\n %d",i,pfirst->athlete[j].name,pfirst->athlete[j].score);break; } } } printf("\n\n\n\t\t\t\t\t\t按任意建 進入下一頁"); getchar(); pfirst = pfirst->next; } // clrscr(); printf("\n運動會結(jié)果:\n\n學(xué)校編號\t男運動員成績\t女運動員成績\t總分"); pfirst = head->next; while ( pfirst->next != NULL ) { printf("\n %d\t\t %d\t\t %d\t\t %d",pfirst->serial,pfirst->menscore,pfirst->womenscore,pfirst->totalscore); pfirst = pfirst->next; } printf("\n\n\n\t\t\t\t\t\t\t按任意建結(jié)束"); getchar(); } void create() { pfirst = (struct schoolstruct *)malloc(sizeof(struct schoolstruct)); pfirst->next = head->next ; head->next = pfirst ; pfirst->count = 1; pfirst->menscore = 0; pfirst->womenscore = 0; pfirst->totalscore = 0; } void Save() {FILE *fp; if((fp = fopen("school.dat","wb"))==NULL) {printf("can't open school.dat\n"); fclose(fp); return; } fwrite(pfirst,sizeof(SCH),10,fp); fclose(fp); printf("文件已經(jīng)成功保存\n"); } void main() { system("cls"); printf("\n\t\t\t 運動會分?jǐn)?shù)統(tǒng)計\n"); printf("輸入學(xué)校數(shù)目 (x>= 5):"); scanf("%d",&nsc); printf("輸入男選手的項目(x<=20):"); scanf("%d",&msp); printf("輸入女選手項目(<=20):"); scanf("%d",&wsp); ntsp = msp + wsp; phead = (int *)calloc(ntsp,sizeof(int)); pafirst = phead; pasecond = phead; input(); calculate(); output(); Save(); }
標(biāo)簽: 源代碼
上傳時間: 2016-12-28
上傳用戶:150501
取各障礙物頂點連線的中點為路徑點,相互連接各路徑點,將機器人移動的起點和終點限制在各路徑點上,利用最短路徑算法來求網(wǎng)絡(luò)圖的最短路徑,找到從起點P1到終點Pn的最短路徑。上述算法使用了連接線中點的條件,因此不是整個規(guī)劃空間的最優(yōu)路徑,然后利用遺傳算法對找到的最短路徑各個路徑點Pi (i=1,2,…n)調(diào)整,讓各路徑點在相應(yīng)障礙物端點連線上滑動,利用Pi= Pi1+ti×(Pi2-Pi1)(ti∈[0,1] i=1,2,…n)即可確定相應(yīng)的Pi,即為新的路徑點,連接此路徑點為最優(yōu)路徑。
標(biāo)簽: 遺傳算法 路徑規(guī)劃 matlab
上傳時間: 2017-05-05
上傳用戶:tttt123
作者:Charles K Alexander ,Matthew N.O Sadiku 內(nèi)容:電路基礎(chǔ)知識,電子工程師必學(xué)課程
標(biāo)簽: 電路基礎(chǔ)
上傳時間: 2021-02-03
上傳用戶:
P P I I CK I I T T3 3 使用 說明--- - 連機 、 脫 機操作試用 MPLAB IDE 軟件一 、 P P I I C CK K I I T3 接 口說 明, , 硬 件 二 、 P P I I C CK K I I T3 連 接 電腦 MPL L AB I I DE 聯(lián)機三 、 聯(lián)機四 、聯(lián)機讀芯片程序五 、 脫機 燒寫 調(diào)試
上傳時間: 2022-03-24
上傳用戶:
本章重點是如何在Wi n d o w s套接字應(yīng)用程序中對I / O(輸入/輸出)操作進行管理。 Wi n s o c k分別提供了“套接字模式”和“套接字I / O模型”,可對一個套接字上的I / O行為加以 控制
標(biāo)簽: 套接 Wi 分 應(yīng)用程序
上傳時間: 2013-12-14
上傳用戶:Shaikh
(1)輸入E條弧<j,k>,建立AOE-網(wǎng)的存儲結(jié)構(gòu) (2)從源點v出發(fā),令ve[0]=0,按拓撲排序求其余各項頂點的最早發(fā)生時間ve[i](1<=i<=n-1).如果得到的拓樸有序序列中頂點個數(shù)小于網(wǎng)中頂點數(shù)n,則說明網(wǎng)中存在環(huán),不能求關(guān)鍵路徑,算法終止 否則執(zhí)行步驟(3)(3)從匯點v出發(fā),令vl[n-1]=ve[n-1],按逆拓樸排序求其余各頂點的最遲發(fā)生時間vl[i](n-2>=i>=2). (4)根據(jù)各頂點的ve和vl值,求每條弧s的最早發(fā)生時間e(s)和最遲開始時間l(s).若某條弧滿足條件e(s)=l(s),則為關(guān)鍵活動.
上傳時間: 2014-11-28
上傳用戶:fredguo
最佳高度問題。 問題描述: 假設(shè)有n個任務(wù)由K個可并行工作的機器完成。完成任務(wù)i需要的時間為t(i)。試設(shè)計一個算法找出完成這n個任務(wù)的最佳調(diào)度,使得完成全部任務(wù)的時間最早。
上傳時間: 2014-12-07
上傳用戶:Amygdala
一個有關(guān)於數(shù)值控制震盪器(NCO)的檔案,用Matlab的Simulink開啟即可.
標(biāo)簽: Simulink Matlab NCO 控制
上傳時間: 2013-12-17
上傳用戶:佳期如夢
這是一個Verilog的電梯控制程序碼,控制樓層為1~4樓,關(guān)開門...等
上傳時間: 2016-05-04
上傳用戶:wyc199288
實現(xiàn)最優(yōu)二叉樹的構(gòu)造;在此基礎(chǔ)上完成哈夫曼編碼器與譯碼器。 假設(shè)報文中只會出現(xiàn)如下表所示的字符: 字符 A B C D E F G H I J K L M N 頻度 186 64 13 22 32 103 21 15 47 57 1 5 32 20 57 字符 O P Q R S T U V W X Y Z , . 頻度 63 15 1 48 51 80 23 8 18 1 16 1 6 2 要求完成的系統(tǒng)應(yīng)具備如下的功能: 1.初始化。從終端(文件)讀入字符集的數(shù)據(jù)信息,。建立哈夫曼樹。 2.編碼:利用已建好的哈夫曼樹對明文文件進行編碼,并存入目標(biāo)文件(哈夫曼碼文件)。 3.譯碼:利用已建好的哈夫曼樹對目標(biāo)文件(哈夫曼碼文件)進行編碼,并存入指定的明文文件。 4.輸出哈夫曼編碼文件:輸出每一個字符的哈夫曼編碼。
上傳時間: 2014-11-23
上傳用戶:shanml
蟲蟲下載站版權(quán)所有 京ICP備2021023401號-1