Generation

translateWed, 04 Jan 2023

Write a function void Mat3_print(Mat3 M) that prints the contents of the matrix M. At this point you should be able to run this program. int main() { Mat3 mat3 = { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 } }; Mat3_print(mat3); return 0; } The output could look like an initialiser for a Mat3, for example: { { 1.000000, 2.000000, 3.000000 }, { 4.000000, 5.000000, 6.000000 }, { 7.000000, 8.000000, 9.000000 } }

void Mat3_print(Mat3 M) { printf("{ { %.6f, %.6f, %.6f },\n { %.6f, %.6f, %.6f },\n { %.6f, %.6f, %.6f } }\n", M.m[0][0],M.m[0][1],M.m[0][2],M.m[1][0],M.m[1][1],M.m[1][2],M.m[2][0],M.m[2][1],M.m[2][2]); }

Questions about programming?Chat with your personal AI assistant