[輸入] 圖的頂點(diǎn)個(gè)數(shù)N,圖中頂點(diǎn)之間的關(guān)系及起點(diǎn)A和終點(diǎn)B [輸出] 若A到B無(wú)路徑,則輸出“There is no path” 否則輸出A到B路徑上個(gè)頂點(diǎn) [存儲(chǔ)結(jié)構(gòu)] 圖采用鄰接矩陣的方式存儲(chǔ)。 [算法的基本思想] 采用廣度優(yōu)先搜索的方法,從頂點(diǎn)A開始,依次訪問(wèn)與A鄰接的頂點(diǎn)VA1,VA2,...,VAK, 訪問(wèn)遍之后,若沒有訪問(wèn)B,則繼續(xù)訪問(wèn)與VA1鄰接的頂點(diǎn)VA11,VA12,...,VA1M,再訪問(wèn)與VA2鄰接頂點(diǎn)...,如此下去,直至找到B,最先到達(dá)B點(diǎn)的路徑,一定是邊數(shù)最少的路徑。實(shí)現(xiàn)時(shí)采用隊(duì)列記錄被訪問(wèn)過(guò)的頂點(diǎn)。每次訪問(wèn)與隊(duì)頭頂點(diǎn)相鄰接的頂點(diǎn),然后將隊(duì)頭頂點(diǎn)從隊(duì)列中刪去。若隊(duì)空,則說(shuō)明到不存在通路。在訪問(wèn)頂點(diǎn)過(guò)程中,每次把當(dāng)前頂點(diǎn)的序號(hào)作為與其鄰接的未訪問(wèn)的頂點(diǎn)的前驅(qū)頂點(diǎn)記錄下來(lái),以便輸出時(shí)回溯。 #include<stdio.h> int number //隊(duì)列類型 typedef struct{ int q[20]
標(biāo)簽: 輸入
上傳時(shí)間: 2015-11-16
上傳用戶:ma1301115706
1.[問(wèn)題描述] 編寫遞歸算法,計(jì)算二叉樹中葉子結(jié)點(diǎn)的數(shù)目 [輸入] 按照先序序列的順序輸入該結(jié)點(diǎn)的內(nèi)容。其輸入abd eh cf i g . [輸出] 按中序序列輸出,輸出的結(jié)果為;dbheaficg并計(jì)算出二叉樹中葉子結(jié)點(diǎn)的數(shù)目為4 [存儲(chǔ)結(jié)構(gòu)] 采用二叉表存儲(chǔ) [算法的基本思想] 采用遞歸方法建立和遍歷二叉樹。首先建立二叉樹的根結(jié)點(diǎn),然后建立其左右子樹,直到空子樹為止,中序遍歷二叉樹時(shí),先遍厲左子樹,后遍厲右子樹,最后訪問(wèn)根結(jié)點(diǎn)。根據(jù)左右子樹的最后一個(gè)結(jié)點(diǎn)計(jì)算出二叉樹中葉子結(jié)點(diǎn)的數(shù)目。 程序如下: #include<stdio.h> #include<malloc.h> #include"stdlib.h"
上傳時(shí)間: 2015-11-16
上傳用戶:GavinNeko
2.[問(wèn)題描述] 編寫遞歸算法,在二叉樹中求位于先序序列中第K個(gè)位置的結(jié)點(diǎn) [輸入] 按照先序序列的順序輸入該結(jié)點(diǎn)的內(nèi)容。其輸入abd eh cf i g 。輸入要求的位置 [輸出] 若二叉樹不空,按先序序列輸出,求出所求位置的結(jié)點(diǎn) [存儲(chǔ)結(jié)構(gòu)] 采用二叉表存儲(chǔ) [算法的基本思想] 采用遞歸方法建立和遍歷二叉樹。首先建立二叉樹的根結(jié)點(diǎn),然后建立其左右子樹,直到空子樹為止,先序遍歷二叉樹時(shí),先遍厲左子樹,后遍厲右子樹,最后訪問(wèn)根結(jié)點(diǎn)并計(jì)算出二叉樹中葉子結(jié)點(diǎn)的數(shù)目和第K個(gè)位置的結(jié)點(diǎn) #include<stdio.h> #include<malloc.h> struct node{ char info struct node*llink,*rlink } typedef struct node NODE
上傳時(shí)間: 2014-01-13
上傳用戶:zm7516678
[問(wèn)題描述] 將N個(gè)關(guān)鍵字去整數(shù)的記錄進(jìn)行整序, 以使所有關(guān)鍵字為非負(fù)數(shù)的記錄排在關(guān)鍵字為負(fù)數(shù)的記錄之前,要求使用最少的附加空間,且算法的時(shí)間復(fù)雜度為O(N) [輸入] 待排序記錄個(gè)數(shù),各關(guān)鍵字的值。 [輸出] 關(guān)鍵字從正負(fù)分開,正數(shù)在前 [存儲(chǔ)結(jié)構(gòu)] 待排序記錄順序存儲(chǔ)。 [算法的基本思想] 快速排序算法每次任取一個(gè)記錄的關(guān)鍵字為標(biāo)準(zhǔn),將其余記錄分為兩組將,N個(gè)關(guān)鍵字去整數(shù)的記錄進(jìn)行整序, 以使所有關(guān)鍵字為非負(fù)數(shù)的記錄排在關(guān)鍵字為負(fù)數(shù)的記錄之前。 #include <iostream> using namespace std #define MAXNUM 100//設(shè)文件的最長(zhǎng)可能長(zhǎng)度 void sort(int* keys, const int len)//排序
上傳時(shí)間: 2014-01-13
上傳用戶:aig85
Software Testing, Second Edition provides practical insight into the world of software testing and quality assurance. Learn how to find problems in any computer program, how to plan an effective test approach and how to tell when software is ready for release. Updated from the previous edition in 2000 to include a chapter that specifically deals with testing software for security bugs, the processes and techniques used throughout the book are timeless. This book is an excellent investment if you want to better understand what your Software Test team does or you want to write better software.
標(biāo)簽: practical Software provides software
上傳時(shí)間: 2014-08-01
上傳用戶:zhaiyanzhong
The ability to write efficient, high-speed arithmetic routines ultimately depends upon your knowledge of the elements of arithmetic as they exist on a computer. That conclusion and this book are the result of a long and frustrating search for information on writing arithmetic routines for real-time embedded systems. With instruction cycle times coming down and clock rates going up, it would seem that speed is not a problem in writing fast routines. In addition, math coprocessors are becoming more popular and less expensive than ever before and are readily available. These factors make arithmetic easier and faster to use and implement. However, for many of you the systems that you are working on do not include the latest chips or the faster processors. Some of the most widely used microcontrollers used today are not Digital Signal Processors (DSP), but simple eight-bit controllers such as the Intel 8051 or 8048 microprocessors.
標(biāo)簽: arithmetic high-speed ultimately efficient
上傳時(shí)間: 2014-11-30
上傳用戶:lizhen9880
this is μC_OS-Ⅱchinese for arm7 operation,include some useful code
標(biāo)簽: operation chinese this C_OS
上傳時(shí)間: 2015-11-25
上傳用戶:klin3139
/// ////單端輸入,定時(shí)啟動(dòng),由T2定時(shí),選擇AIN0.3為ADC0轉(zhuǎn)化通道//////////////// //////single.c/////////////////////////////////// #include "lcd.h"http://筆者所寫的LCD顯示頭文件,具體見LCD章節(jié) /*若讀者沒有條件使用"lcd.h"的各顯示和鍵盤函數(shù),則可在lcd.h文件中如下定義:
上傳時(shí)間: 2015-11-26
上傳用戶:vodssv
ApMl provides users with the ability to crawl the web and download pages to their computer in a directory structure suitable for a Machine Learning system to both train itself and classify new documents. Classification Algorithms include Naive Bayes, KNN
標(biāo)簽: the provides computer download
上傳時(shí)間: 2015-11-29
上傳用戶:ywqaxiwang
此程序用來(lái)分離一個(gè)字符串中的數(shù)字及字符,string.zip
上傳時(shí)間: 2015-12-02
上傳用戶:wab1981
蟲蟲下載站版權(quán)所有 京ICP備2021023401號(hào)-1