answersLogoWhite

0


Best Answer

its simple

just do this swappping

for(i=0;i<m;i++) /*A*/

for(j=0;j<i;j++) /*B*/

{

x=a[i][j];

a[i][j]=a[j][i];

a[j][i]=x;

}

I think A and B need a change :

/*Permutation : */

for ( i = 0 ; i <= lig ; i++ ) /*A*/

for ( j = 0 ; j <= i ; j++ ) /*B*/

{

int permut = MatA[i][j] ;

MatA[i][j] = MatA[j][i] ;

MatA[j][i] = permut ;

}

/*End of permutation */

printf("\nDISPLAY MATRIX : \n") ;

for ( i = 0 ; i < col ; i++ )

{

for ( j = 0 ; j < lig ; j++ )

{

printf("%d", MatA[i][j]) ;

}

printf("\n") ;

}

User Avatar

Wiki User

14y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

15y ago

public static void transpose(int[][] a, int[][] b, int width, int height)

{

for (int i = 0; i < width; i++)

{

for (int j = 0; j < height; j++)

{

b[j][i] = a[i][j];

}

}

}

template <class T>

void transpose( std::vector< std::vector<T> > a,

std::vector< std::vector<T> > b,

int width, int height)

{

for (int i = 0; i < width; i++)

{

for (int j = 0; j < height; j++)

{

b[j][i] = a[i][j];

}

}

}

This answer is:
User Avatar

User Avatar

Wiki User

13y ago

for two dimensional array simply write :

printf("\n transposed matrix is :\n");

for(i=0;i<2;i++)

{

for(j=0;j<2;j++)

{

printf("%d",a[j][i]);

}

printf("\n");

}

remember it will work for

2 dimensional array only

This answer is:
User Avatar

User Avatar

Wiki User

13y ago

A two-dimensional array is an array of arrays.

int[][] xs; // xs is an array in which each element is its own array of ints

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is a two dimensional array in c?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

How do you initialise a two dimentional array?

C provides rectangular multidimensional arrays. In C, a two-dimensional array is really a one-dimensional array, each of whose elements is an array. An array is initialized by a list of initializations in braces; each row of a two-dimensional array is initialized by a corresponding sub-list. Example of two dimensional array initialization: char array_example[2][4] = { {11, 12, 13, 14}, {21, 22, 23, 24} };


Differentiate single dimensional array to double dimensional array?

A single dimensional array is an array of items. A two-dimensional array is an array of arrays of items.


Columns and rows in c programming?

Do you perhaps mean -- a two-dimensional array? A two dimensional array is nothing more than a one-dimensional array where every element is a one-dimensional array. int matrix[4][5]; C is a row-major language thus the first dimension refers to the number of rows. Here we have declared an array of 4 rows, where each row is an array of 5 elements of type int.


What does a 2 dimensional array do?

A two dimensional array is a one-dimensional array of one-dimensional arrays. That is, just as we can have an array of integers, we can also have an array of integer arrays. This idea can be extended such that we can have an array of two-dimensional arrays (a three-dimensional array), and so on. We typically use a two-dimensional array to represent a table of rows and columns, where each row is a one-dimensional array.


Explain the Different types of array?

one dementional array and two dementional array

Related questions

How do you initialise a two dimentional array?

C provides rectangular multidimensional arrays. In C, a two-dimensional array is really a one-dimensional array, each of whose elements is an array. An array is initialized by a list of initializations in braces; each row of a two-dimensional array is initialized by a corresponding sub-list. Example of two dimensional array initialization: char array_example[2][4] = { {11, 12, 13, 14}, {21, 22, 23, 24} };


Differentiate single dimensional array to double dimensional array?

A single dimensional array is an array of items. A two-dimensional array is an array of arrays of items.


Columns and rows in c programming?

Do you perhaps mean -- a two-dimensional array? A two dimensional array is nothing more than a one-dimensional array where every element is a one-dimensional array. int matrix[4][5]; C is a row-major language thus the first dimension refers to the number of rows. Here we have declared an array of 4 rows, where each row is an array of 5 elements of type int.


How does two dimensional array differ from single dimensional array?

A one dimensional array is a scalar value repeated one or more times.A two dimensional array is an array of one dimensional arrays.A three dimensional array is an array of two dimensional arrays, and so forth.The one dimensional array is like a list of things, where the two dimensional array is like an array of things. (Think one row of a spreadsheet versus the whole spreadsheet.)[addendum]Every level of array depth is also a level of pointer depth. For example: A 3 dimensional int array is an int***. So a one dimensional int array is an int*, and a two dimensional int array is an int**. This is only important if you are doing pointer work, but it can become very important.


What is a multi array?

A two-dimensional array is the simplest multi-dimensional array and is implemented as a one-dimensional array where every element is itself a one-dimensional array. We can imagine a two-dimensional array as being a table of rows and columns where every row is an array in its own right. A three-dimensional array is simply a one-dimensional array of two-dimensional arrays, which can be imagined as being an array of tables. Extending the concept, a four-dimensional array is a table of tables. Multi-dimensional arrays may be jagged. That is, a two-dimensional array may have rows of unequal length. Unlike regular arrays, jagged arrays cannot be allocated in contiguous memory. Instead, we use the outer array (the first dimension) to store pointers to the inner arrays. An array of strings (character arrays) is an example of a two-dimensional jagged array.


What is single dimensional array in c plus plus?

A one dimensional array is an array of objects that goes in one "direction". Any array with only one [] is a one dimensional array. For example: int numbers[6]; is a one dimensional array. int numbers[6][3]; is a two dimensional array.Graphical terms:One dimensional array[4]:14 - 75 - 8164 - 234Two dimensional array[2][3]:47 - 178108 - 8517 - 128It didn't come out quite how I wanted it...


What is a table array?

A two-dimensional array.


How you create table in c language?

The simplest way to create a table in C is to use a two-dimensional array.


What does a 2 dimensional array do?

A two dimensional array is a one-dimensional array of one-dimensional arrays. That is, just as we can have an array of integers, we can also have an array of integer arrays. This idea can be extended such that we can have an array of two-dimensional arrays (a three-dimensional array), and so on. We typically use a two-dimensional array to represent a table of rows and columns, where each row is a one-dimensional array.


Explain the Different types of array?

one dementional array and two dementional array


How many types of arrays in c?

An array is simply a contiguous block of memory containing two or more elements. There are two types of array: a static array which is allocated on the stack at compile time; and a dynamic array which is allocated on the heap at runtime. Both can be one-dimensional or multi-dimensional. A one-dimensional array can be likened to a row (or column) of chessboard squares, with as many squares as required to store all the elements. A multi-dimensional array is any array with two or more dimensions. A two-dimensional array can be likened to the whole chessboard, where any square can be identified by its row and column index. However the dimensions needn't be equal. A two-dimensional array can also be imagined as a one-dimensional array where every element is simply another one-dimensional array. Three-dimensional arrays can be likened to a cube, or as a one-dimensional array of two-dimensional arrays. A four-dimensional array can be linked to a one-dimensional array of three-dimensional arrays, and so on. Although every one-dimensional array must be allocated in contiguous memory, multi-dimensional arrays can be dynamically allocated so that each dimension is itself a separately allocated one-dimensional array of pointers to the next dimension, making it possible to allocate extremely large arrays over a series of smaller allocations rather than as a single contiguous block.


How can a list of strings be stored within a two dimensional array?

Think of the strings as writing on lines of paper. Paper is a two dimensional surface. The computer array is the equivalent of the two dimensional paper.