0

How i can make a Matrix by using 2 dimension arrays and function ?
please i need answer
thanks.

Edited by محمد_44

2
Contributors
3
Replies
27
Views
3 Years
Discussion Span
Last Post by David W
0

Can you show us what code you have tried?

Start with a working C++ shell ... and add from there, in steps.

Show us where you are having trouble(s) ...

Edited by David W

0

that is my code
the program is
the user will input number of test cases\the number of raws in matrix n=2,3,4,5,6,7,8..........100/then he write a matrix/then my program check his matrix if it symmetric or not/

#include <iostream>
#include <algorithm>
using namespace std;
bool Matrix (int **arr,int i, int j ,int x)
{
    for (int i = 0; i < x; i++)
    {
        arr[i] = new int[x];
        for (int j = 0; j < x; j++)
        {
            arr[j] = new int[x];
            cin >> arr[i][j];
            for (int h = 0; h < x; h++)
    {
        if (arr[i][j] == arr[j][i])return true;
    }
    return false;


}
int main()
{
    int x, t;
    cin >> t;
    for (int k = 0; k <= t; k++)
    {
        cout << "N =";
        cin >> x;
        int **arr;
        arr = new int *[x];
        for (int i = 0; i < x; i++)
        {
            arr[i] = new int[x];
            for (int j = 0; j < x; j++)
            {
                arr[j] = new int[x];
                cin >> arr[i][j];
                if (Matrix(arr, i, j, x))
                    cout << "Symmetric";
                else{ cout << "un Symmetric"; }
            }
        }
        return 0;
    }
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.