簡體   English   中英

稀疏矩陣相乘,鏈表

[英]Multiplication of sparse matrix, linked list

我有2套排序的鏈表A和B,我想得到A * B的乘積。對於A,這很容易,因為它只是一個普通的嵌套for循環。 B呢? 最初,我想到將3嵌套用於循環,但是由於我將使用指針,因此無法使用B [i] [j]。 有什么主意嗎?

我有點想辦法了。

while (A != NULL)      //your first list
{                   
                       // store your row value and col in variables
   while (B != NULL)   // second list
   {
      if (colB == rowA) // you check if the b col is equals to a row, if yes you can
                        // start storing the values inside the 3rd link. 



    }

}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM