基于事件驅動的串口通訊控件
消息幀數(shù)據格式:
1 0 A B X X
其中 10 為消息標識,
AB表示文本長度,L=A*100+B
XX為配位字符,任意
控制幀數(shù)據格式
0 1 A B M N
其中 01為控制標識,
AB為請求標識
MN為附加標識
11表示請求對方接收文件,M表示描述字串中文件名子串的長度
N表示描述字串中文件大小子串的長度
10通知對方放棄傳輸
00通知文件傳輸完畢
01請求對方發(fā)送數(shù)據, MN為10請求發(fā)送下一個
MN為00請求重發(fā)
數(shù)據幀數(shù)據格式
0 0 A B M N
其中 00 為數(shù)據標識,
AB表示數(shù)據長度,L=A*100+B
MN為校驗,M*100+N=A+B
acm HDOJ 1051WoodenSticks
Description:
There is a pile of n wooden sticks. The length and weight of each stick are known in advance. The sticks are to be processed by a woodworking machine in one by one fashion. It needs some time, called setup time, for the machine to prepare processing a stick. The setup times are associated with cleaning operations and changing tools and shapes in the machine. The setup times of the woodworking machine are given as follows:
(a) The setup time for the first wooden stick is 1 minute.
(b) Right after processing a stick of length l and weight w , the machine will need no setup time for a stick of length l and weight w if l<=l and w<=w . Otherwise, it will need 1 minute for setup.
[輸入]
圖的頂點個數(shù)N,圖中頂點之間的關系及起點A和終點B
[輸出]
若A到B無路徑,則輸出“There is no path” 否則輸出A到B路徑上個頂點
[存儲結構]
圖采用鄰接矩陣的方式存儲。
[算法的基本思想]
采用廣度優(yōu)先搜索的方法,從頂點A開始,依次訪問與A鄰接的頂點VA1,VA2,...,VAK, 訪問遍之后,若沒有訪問B,則繼續(xù)訪問與VA1鄰接的頂點VA11,VA12,...,VA1M,再訪問與VA2鄰接頂點...,如此下去,直至找到B,最先到達B點的路徑,一定是邊數(shù)最少的路徑。實現(xiàn)時采用隊列記錄被訪問過的頂點。每次訪問與隊頭頂點相鄰接的頂點,然后將隊頭頂點從隊列中刪去。若隊空,則說明到不存在通路。在訪問頂點過程中,每次把當前頂點的序號作為與其鄰接的未訪問的頂點的前驅頂點記錄下來,以便輸出時回溯。
#include<stdio.h>
int number //隊列類型
typedef struct{
int q[20]