Help a Brotha out

I really need help with this project.


this is the scenario
A matrix (two-dimensional array) is symmetric if:
it is a square matrix (its sides are equal)
its elements are placed symmetrically about the main diagonal (the diagonal that goes from upper-left to bottom-right vertex)
To be concise - this is a symmetric matrix:
1 2 3
2 1 2
3 2 1
and this is not:
1 2 3
2 1 2
4 2 1
The code presented below declares 4x4 matrix initially filled with some data. Your task is to complete the code and to answer the
fundamental question: is that matrix symmetrical or not.
When you complete your code, play with the matrix a bit:change its dimensions, move some of the elements - be sure that your code
works well in any situation.


(this is the base code)
#include <iostream>
using namespace std;
int main(void) {
double matrix[][4] = { { 1, 2, 3, 4 },
{ 2, 2, 3, 1 },
{ 3, 3, 3, 2 },
{ 4, 1, 2, 4 } };
int side = sizeof(matrix[0]) / sizeof(matrix[0][0]);
bool issymmetric = true;
// Insert your code here
if(issymmetric)
cout << "The matrix is symmetric" << endl;
else
cout << "The matrix is not symmetric" << endl;
return 0;
}
@tojo,
This is your third post ... and you are yet to show any of your own code.
Whilst we've had quite a lot of fun with your previous questions (on palindromes), maybe it's time you showed some of your own efforts?
this is the base code I have to build off of.
I just dont know what to do with it
What, specifically, are you having trouble with?

Do you have a problem understanding some (or all) of the requirements of the question?

Do you have a problem figuring an algorithm for determining whether a matrix is diagonal?

Do you have a problem with some aspect of C++ syntax?

Do you have a problem with how to design the code?

Do you have some other problem I haven't thought of?

I can assure you, however many people here you think can read your mind, the real number is much lower. Give us something to work with. Be specific.
This is not a homework site. We don't do your homework for you. Pasting an assignment and expecting us to provide an answer will not yield much helpful information.

Start by adding code tags to your post. Before your any code that you paste add the tag [code], and after your code, add the tag [/code]. If you do this, it will make it easier for us to read the code, and make us more willing to help you. The more you try to make our job easier, the more help you are likely to get.

Second, make an attempt at solving the problem yourself. When you run across a problem, ask us about it. For instance:

- It won't compile (and here are the error messages)
- It won't link (and here are the error messages)
- It compiles but it won't run (and any error messages you get)
- It runs, but it doesn't give the correct response (and add the expected and received responses)

Third, break your assignment into steps. Do one step and see what you get. Then do another step and see what you get. Build up until you run into a problem you can ask us about or you finish the assignment. For your first step, just try to print out the 2-d matrix. Make sure you can print out what you think you have. Then print out just the diagonal values. When you can do that, you should have a foundation for solving the rest of the problem.

Edit: As a beginner you might not be able to discriminate between compiler and linker errors. That's ok, just paste your error messages and we can help you figure out what's wrong.
Last edited on
i did i just dont understand how to like go through the matrix
A matrix (two-dimensional array) is symmetric if:
1. it is a square matrix (its sides are equal)
2. its elements are placed symmetrically about the main diagonal (the diagonal that goes from upper-left to bottom-right vertex)


The first part should be almost easy.

(The code you were given is <unspeakable>.)
Given code below:
1
2
3
4
5
6
7
int main()
{
  constexpr int Cols {4};
  double matrix[][Cols] =
   { 1, 2, 3, 4, 2, 2, 3,
     1, 3, 3, 3, 2, 4 };
  constexpr int Rows = sizeof(matrix[0]) / sizeof(matrix[0][0]);

How to test whether condition 1 is true or false?


For condition 2, look at the matrix below:
a b c d e
. f g h i
. . j k l
. . . m n
. . . . o

Please replace the dots with letters so that it becomes symmetric.


Edit:
i just dont understand how to like go through the matrix

How do you go through an array?
Last edited on
Topic archived. No new replies allowed.