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

Recommended Answers

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) ...

Jump to Post

All 3 Replies

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) ...

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;
    }

You forgot to ...

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.