鄰接矩陣類的根是A d j a c e n c y W D i g r a p h,因此從這個類開始。程序1 2 - 1給出了類的描述。程 序中,先用程序1 - 1 3中函數Make2DArray 為二組數組a 分配空間,然后對數組a 初始化,以描述 一個n 頂點、沒有邊的圖的鄰接矩陣,其復雜性為( n2 )。該代碼沒有捕獲可能由M a k e 2 D A r r a y 引發的異常。在析構函數中調用了程序1 - 1 4中的二維數組釋放函數D e l e t e 2 D
標簽: 矩陣
上傳時間: 2013-12-21
上傳用戶:lanjisu111
實現最優二叉樹的構造;在此基礎上完成哈夫曼編碼器與譯碼器。 假設報文中只會出現如下表所示的字符: 字符 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 要求完成的系統應具備如下的功能: 1.初始化。從終端(文件)讀入字符集的數據信息,。建立哈夫曼樹。 2.編碼:利用已建好的哈夫曼樹對明文文件進行編碼,并存入目標文件(哈夫曼碼文件)。 3.譯碼:利用已建好的哈夫曼樹對目標文件(哈夫曼碼文件)進行編碼,并存入指定的明文文件。 4.輸出哈夫曼編碼文件:輸出每一個字符的哈夫曼編碼。
上傳時間: 2014-11-23
上傳用戶:shanml
替代加密: A B C D E F G H I J K L M N O P Q R S T U V W 密文 Y Z D M R N H X J L I O Q U W A C B E G F K P 明文 X Y Z T S V I HAVE A DREAM!# 密文?? 用ARM編程實現替代加密。
標簽: 加密
上傳時間: 2016-07-17
上傳用戶:qq521
這是用MICROCHIP PIC做的可控制三相或單相感應馬達正反轉作為大門開啟用
上傳時間: 2014-08-10
上傳用戶:linlin
VFD-A 內部的參數資料可使用內部 RS-485 串聯通訊介面,設定及修改並可控制交流電機驅動 器運轉及監測交流電機驅動器的運轉狀態,可提高自動化的能力。
上傳時間: 2013-12-24
上傳用戶:invtnewer
凌力爾特公司提供了一個規模龐大且不斷成長的高電壓 DC/DC 轉換器繫列,這些器件是專為驅動高功率 LED 而設計的。
上傳時間: 2013-11-12
上傳用戶:playboys0
一、問題的提出: 某廠根據計劃安排,擬將n臺相同的設備分配給m個車間,各車間獲得這種設備后,可以為國家提供盈利Ci j(i臺設備提供給j號車間將得到的利潤,1≤i≤n,1≤j≤m) 。問如何分配,才使國家得到最大的盈利L 二.算法的基本思想: 利用動態規劃算法的思想,設將i臺設備分配給j-1個車間,可以為國家得到最大利潤Li (j-1)(1≤i≤n,1≤j≤m),那么將這i臺設備分配給j個車間,第j個車間只能被分配到0~i臺,所以我們只要算出當第j個車間分配到t(0<=t<=i)臺時提供的最大利潤Lt(j-1)+C(i-t)j,
標簽:
上傳時間: 2016-09-19
上傳用戶:希醬大魔王
一個基于GTK+的單詞數值計算器,1、 按照規則計算單詞的值,如果 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 26個字母(全部用大寫)的值分別為 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26,如: WINJACK這個單詞的值就為:W+I+N+J+A+C+K=23+9+14+1+3+11=71% HARDWORK=H+A+R+D+W+O+R+D=8+1+18+4+23+15+18+11=98% LOVE=L+O+V+E=12+15+22+5=54% LUCK=L+U+C+K=12+21+3+11=47% ATTITUDE= A+T+T+I+T+U+D+E=1+20+20+9+20+24+4+5=100% 2、對程序的界面布局參考如下圖所示,在第一個單行文本框輸入一個單詞,點擊“計算”按鈕,按照以上算法計算出該單詞的值。 3、如果在最下面的單行文本框輸入一個文件路徑,此文件每行記錄一個單詞,那么經過程序計算出各個單詞的值,并把結果輸出到當前目錄下result.txt文件中。如果文件不存在,應該提示錯誤。
上傳時間: 2014-01-11
上傳用戶:康郎
旅行商問題(Travelling Salesman Problem, 簡記TSP,亦稱貨郎擔問題):設有n個城市和距離矩陣D=[dij],其中dij表示城市i到城市j的距離,i,j=1,2 … n,則問題是要找出遍訪每個城市恰好一次的一條回路并使其路徑長度為最短。
標簽: Travelling Salesman Problem TSP
上傳時間: 2017-09-14
上傳用戶:彭玖華
#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; /*分數*/ int range; /**/ int item; /*項目*/ }ATH; typedef struct schoolstruct /*學校*/ { int count; /*編號*/ int serial; /**/ int menscore; /*男選手分數*/ int womenscore; /*女選手分數*/ 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這個項目已經存在請選擇其他的數字\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超過學校數目,請重新輸入"); 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繼續輸入運動項目(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號學校的結果成績:",pfirst->serial); printf("\n\n項目的數目\t學校的名字\t分數"); 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運動會結果:\n\n學校編號\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按任意建結束"); 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("文件已經成功保存\n"); } void main() { system("cls"); printf("\n\t\t\t 運動會分數統計\n"); printf("輸入學校數目 (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(); }
標簽: 源代碼
上傳時間: 2016-12-28
上傳用戶:150501