CMakeLists辅导、C/C++​ Time it Took Matthew 辅导

- 首页 >> C/C++编程


Time it Took Matthew

About 40 minutes but I forgot to time myself this time :(

What to submit

A zip file containing

1. A CMakeLists.txt to compile your submission

2. All of your source files for your answer (.c and .h files)

Make sure to not accidentally zip the folder that contains your answer but instead the files

themselves.

Zip This

Don’t Zip This

Problem Description

Write a program to find the determinant of a matrix. For how to find a determinant of a matrix

please see: https://www.mathsisfun.com/algebra/matrix-determinant.html. Here you can find a

determinant calculator to help you check your work:

https://www.symbolab.com/solver/matrix-determinant-calculator

Problem Details

1. The name of the file containing the matrix will be given on the command line

a. This name will always be valid

2. The structure of a matrix file is

Num_rows num_cols

row1_val1 row1_val2 row1_val3…

row2_val1 row2_val2 row2_val3…

...

3. The files will always be structured correctly

4. The matrices will always be square, ie N X N

5. The values in the matrix are real numbers

Additional Requirements

1. You should always print your answer to 2 decimal places

2. You must use a struct to represent your matrix object

a. If you do not use a struct the TAs will manually deduct 50% from your score after

the due date has passed

3. Your solution should consist of at least 3 source files

a. matrix.c

b. matrix.h

c. Main.c

4. In order to ensure that your CMakeLists.txt generates the correctly named executable,

add the following bit of code to the end of your CMakeLists.txt

a. set_target_properties(exeName

PROPERTIES

OUTPUT_NAME "FindDeterminant"

SUFFIX ".out")

b. Where exeName is the first argument to add_executable

i. So if you had add_executable(problem3 …) then you should

replace exeName with problem3

c. I’ve included an example CMakeLists.txt for that has this edit done on it already

Hints

1. This problem is recursive

2. Make sure to only open the file in read (“r”) mode. If you open it in read and write (“r+”)

mode or write (“w”) mode you will get an error as you only have read permissions for the

matrix files

3. You are free to write as many functions as you want, so take advantage of that fact and

break the problem down into lots of steps

Example

In the following example, input has been underlined to help you tell it apart from what you

should output. You don’t need to underline anything, it is just a visual aid for you.

Assume the file 3X3Matrix.txt had the following contents

./findDeterminant.out 3X3Matrix.txt

The determinant is 0.00.



站长地图