Results 1 to 3 of 3

Thread: Sorting Two Dimensional Arrays

  1. #1
    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); 
    	  Login (ia, n); 
    	  sx1 (ia, n); 
      )

  2. #2
    Join Date
    May 2008
    Posts
    2,297

    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. #3
    Join Date
    May 2008
    Posts
    2,389

    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.

Similar Threads

  1. How can I use parallel_for to pass two dimensional arrays
    By Tamonash in forum Software Development
    Replies: 7
    Last Post: 08-10-2010, 12:04 AM
  2. Dynamic memory allocation for two-dimensional arrays
    By Ucchal in forum Technology & Internet
    Replies: 1
    Last Post: 23-09-2010, 06:23 PM
  3. Two Dimensional Arrays in JavaScript
    By Bettina in forum Software Development
    Replies: 5
    Last Post: 15-12-2009, 02:01 PM
  4. Two dimensional array to a function
    By Chrisch in forum Software Development
    Replies: 3
    Last Post: 27-11-2009, 12:47 PM
  5. Three dimensional COMPUTER-MOUSE !
    By jesse in forum Portable Devices
    Replies: 0
    Last Post: 26-07-2008, 12:30 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,711,655,467.07989 seconds with 17 queries