metricmatlab
ch ¬ ng 4
Ma trË n - c¸ c phÐ p to¸ n vÒ ma trË n.
4.1 Kh¸ i niÖ m:
- Trong MATLAB d÷ liÖ u ® Ó ® a vµ o xö lý d íi d¹ ng ma trË n.
- Ma trË n A cã n hµ ng, m cét ® î c gä i lµ ma trË n cì n m. § î c ký hiÖ u An m
- PhÇ n tö aij cñ a ma trË n An m lµ phÇ n tö n» m ë hµ ng thø i, cét j .
- Ma trË n ® ¬ n ( sè ® ¬ n lÎ ) lµ ma trË n 1 hµ ng 1 cét.
- Ma trË n hµ ng ( 1 m ) sè liÖ u ® î c bè trÝ trª n mét hµ ng.
a11 a12 a13 ... a1m
- Ma trË n cét ( n 1) sè liÖ u ® î c bè trÝ trª n 1 cét.
鄰接矩陣類的根是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
HDOJ ACM
input:The input consists of T test cases. The number of test cases ) (T is given in the first line of the input. Each test case begins with a line containing an integer N , 1<=N<=200 , that represents the number of tables to move. Each of the following N lines contains two positive integers s and t, representing that a table is to move from room number s to room number t (each room number appears at most once in the N lines). From the N+3-rd line, the remaining test cases are listed in the same manner as above.