TechArena Community Sorting Two Dimensional Arrays

#1
20-03-2009
 Member Join Date: Dec 2008 Posts: 37
Sorting Two Dimensional Arrays

I have a sort matrix 1 to the new array. Currently, I am using the following method to sort,

Code:
``` # include <stdio.h>
# include <math.h>
100 # define
void Login (int ia [m] [m], int & n);
sx1 void (int ia [m] [m], int n);
HV void (int & x, int & y)
(
int tam;
tam = x;
x = y;
y = tam;
)
void Login (int ia [m] [m], int & n)
(
int i, j;
for (i = 0; i <n, i + +)
for (j = 0 j <n, j + +)
(
printf ( "\ n ia [% d] [% d] =", i +1, j +1);
scanf ( "% d", & ia [i] [j]);
)
)
sx1 void (int ia [m] [m], int n)
(
int i, j, k, r, ib [100];
for (i = 0; i <n, i + +)
(
k = 0;
for (j = 0; i <n; j + +)
(
ib [k] = ia [i] [j];
k + +;
)
for (j = 0, j <= k-1, j + +)
for (j = r +1, r <= k, r + +)
if (ib [j] ib [r])
HV (IB [j], ib [r]);
for (j = 0, j <= k, j + +)
printf ( "% d", ib [j]);
printf ( "\ n");
)

)
void main ()
(
int ia [100] [100], n;
scanf ( "% d", & n);
sx1 (ia, n);
)```
#2
20-03-2009
 Member Join Date: May 2008 Posts: 2,293
Re: Sorting Two Dimensional Arrays

In fact you can view each line as 1-dimensional array 1, so the change is your place on the 1-dimensional array, where it should create a new array read:
Code:
``` / / Sorted increasing data on 1 row
for (int i = 0, i <row, i + +)
for (int j = 0 j <column-1, j + +)```
#3
20-03-2009
 Member Join Date: May 2008 Posts: 2,383
Re: Sorting Two Dimensional Arrays

Why is "it not working"? It should work the same way but you just have two sets of indices instead of one.

 Tags: