CENG205 Assignment1
CENG205 Assignment1
2023
• Read an input file (with a fixed name of input.txt) that is located near your executable.
• Input file contains 3 lines of information:
o 1st line contains dimension (N) of triangular matrices that will be multiplied. Notice
that upper triangular matrices are square matrices of N x N.
o 2nd line contains content of first upper triangular matrix (matrix A) in a 1D array
form excluding zeros. Non-zero values in the matrix are separated with blank
characters.
o 3rd line contains content of first upper triangular matrix (matrix B) in a 1D array
form excluding zeros. Non-zero values in the matrix are separated with blank
characters.
• Example input file content:
4
1 2 3 4 6 7 8 11 12 16
16 15 14 13 11 10 9 6 5 1
• Example matrices given above can be demonstrated as:
1 2 3 4 16 15 14 13
𝐴 = [0 6 7 8 ] 𝐵=[0 11 10 9]
0 0 11 12 0 0 6 5
0 0 0 16 0 0 0 1
• Represent all of the triangular matrices using a 1D array structure, excluding zeros, in your
program. You are not allowed to use 2D arrays or any other data structure. You must
perform the multiplication using those 1D arrays.
• Result of the multiplication of the example matrices:
16 37 52 50
𝐶 =𝐴×𝐵 =[0 66 102 97]
0 0 66 67
0 0 0 16
06.11.2023
• Print the multiplication result as a 1D array in the same format of the input matrices and
also as a traditional matrix (2D array) in which values in each row are separated by tab (“\t”)
characters. Use a blank line between these two output forms.
• Example output of the above given matrices:
16 37 52 50 66 102 97 66 67 16
16 37 52 50
0 66 102 97
0 0 66 67
0 0 0 16