Question
Without using a 2D array Write a program in C++ With the user input find out The matrix is N x N The matrix determinant
Without using a 2D array
Write a program in C++
With the user input find out
The matrix is "N x N"
The matrix determinant
User input is entered only with spaces and enter for the next line, example: "This is all the user will input", theres no press 1 to keep adding, or 2 to exit.
1 -2 3
4 5 -6
7 -8 9
how can i use getline(cin, xxxx) to read this, the idea is to read the first line "1 -2 3" and count how many numbers/columns in the row, so that i can then loop the other rows with an expected number of rows and columns, if the row is incomplete an error message should pop up.
Example:
---------------------------------------
User Input 1:
1 2 -3
4 5 0
Output 1:
Not a square matrix!
---------------------------------------
User Input 2:
1 0 2
-1 0 -1
0 1 0
Output 2:
Yes! Matrix is square N x N, where n is = 3.
the determinant is: -1
---------------------------------------
User Input 3:
1 2 3 4 5
2 3 4 5 6
3 4 5 6 7
4 5 6 7 8
5 6 7 8 9
Output 3:
Yes! Matrix is square N x N, where n is = 5.
The determinant is: 0
---------------------------------------
User Input 4:
11 21 31 41 51
-2 3 -4 5 6
13 14 15 16 17
4 -5 6 -7 8
-5 6 -7 8 -9
Output 4:
Yes! Matrix is square N x N, where n is = 5.
The determinant is: 7616
---------------------------------------
User Input 5:
1 2 3
4 5 6
7 8
Output 5:
Not a square matrix!
---------------------------------------
Please keep in mind negative numbers are also allowed, I need to use linked list or vector of vectors, but not a 2D-array
Thank you
Thank you for reading, we can not use a 2D-array or an array so Linked list or vectors are the options, but mainly I cant seem to get the user input to start this. thank you
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started