代寫C C++ Java Python 視頻講解客服在線客服在線

代做國外C C++ Java程序 Python QQ 2365427650 Email [email protected] 免費咨詢編程問題

« Caesar’s cipher MIPSArrayLists »

sparse matrices

Write code to complete a program (download it from Stream) that reads in two sparse matrices from *.txt
files
and stores them as linked lists (dynamic memory). Use either the c or cpp start-up code available on
Stream. The prototype reads text files in a specific format, with the first lines indicating the number of rows
and columns (see example on Stream).
Write the function that adds the two matrices together and produce a result matrix. The result matrix must
also be stored as a linked list. We are assuming that the matrices are too large to fit into memory as arrays,
thus all calculations must be carried out with the matrices stored in their linked list format.
Write a display function that shows all three matrices in the usual matrix format.
Write a display function that shows all three linked lists in order of elements.
Note 1: The programs should read the matrices from the *.txt files, NOT from keyboard. Use the sample
codes provided on Stream. Use either the C or the C++ style (both files provided on Stream).
Note 2: Make sure that values of zero are not nodes in the linked list (after all, that's the point in
implementing the sparse matrix code!).
Note 3: The output must be in this format. This example has 4x4 matrices:
Matrix 1: 1 2 3 4 5
0 1 0 0
0 0 2 0
0 3 0 4
0 0 0 5
Matrix 2: 1 1 2 3 4 10 3 3
1 1 2 0
0 0 3 0
0 4 0 10
0 0 3 3
Matrix Result: 1 2 2 5 7 14 3 8
1 2 2 0
0 0 5 0
0 7 0 14
0 0 3 8
If the matrix is all zeros, it should be printed like this, indicating that the corresponding linked-list is empty:
Matrix 2:
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0

  • 相關文章:

發表評論:

◎歡迎參與討論,請在這里發表您的看法、交流您的觀點。

最新評論及回復

最近發表

Powered By Z-Blog 1.8 Walle Build 100427

Copyright 代寫C.

体彩25选5开奖结果