473,406 Members | 2,705 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

How to sort array and eliminate duplicate array?

16
Hi...

I'm having some difficulties to sort two different array (say X and Y), these arrays state the coordinate in x and y axis..so, if X change, Y has to change.

I have unsorted array and I want to eliminate array with the same value...

Here's my code which doesn't work:

Expand|Select|Wrap|Line Numbers
  1.  
  2. #include <stdlib.h>
  3. #include <math.h>
  4. #include <stdio.h>
  5. #include <conio.h>
  6.  
  7.  
  8. int main ()
  9. {
  10.      float X[4][4][24],Y[4][4][24],P[4][4][24],Q[4][4][24],R[4][4][24],S[4][4][24];
  11.       int i,j,k,l,m,n,a,b,c,d;
  12.  
  13.  
  14. X[0][0][0]=-1.414214;    Y[0][0][0]=0.000000;
  15. X[0][0][1]=-1.414214;    Y[0][0][1]=0.000000;
  16. X[0][0][2]=-1.000000;    Y[0][0][2]=0.414214;
  17. X[0][0][3]=-1.414214;    Y[0][0][3]=0.000000;
  18. X[0][0][4]=-1.000000;    Y[0][0][4]=0.000000;
  19. X[0][1][0]=-0.707107;    Y[0][1][0]=0.707107;
  20. X[0][1][1]=0.000000;    Y[0][1][1]=0.000000;
  21. X[0][1][2]=-1.000000;    Y[0][1][2]=0.414214;
  22. X[0][1][3]=0.000000;    Y[0][1][3]=0.000000;
  23. X[0][1][4]=0.000000;    Y[0][1][4]=0.000000;
  24. X[0][1][5]=0.000000;    Y[0][1][5]=0.000000;
  25. X[0][1][6]=0.000000;    Y[0][1][6]=0.000000;
  26. X[0][1][7]=-1.000000;    Y[0][1][7]=0.000000;
  27. X[0][1][8]=0.000000;    Y[0][1][8]=0.000000;
  28. X[0][2][0]=-1.414214;    Y[0][2][0]=0.000000;
  29. X[0][2][1]=-1.414214;    Y[0][2][1]=0.000000;
  30. X[0][2][2]=-1.000000;    Y[0][2][2]=-0.414214;
  31. X[0][2][3]=-1.000000;    Y[0][2][3]=0.000000;
  32. X[0][3][0]=-0.707107;    Y[0][3][0]=-0.707107;
  33. X[0][3][1]=0.000000;    Y[0][3][1]=0.000000;
  34. X[0][3][2]=-1.000000;    Y[0][3][2]=-0.414214;
  35. X[0][3][3]=0.000000;    Y[0][3][3]=0.000000;
  36. X[0][3][4]=0.000000;    Y[0][3][4]=0.000000;
  37. X[0][3][5]=0.000000;    Y[0][3][5]=0.000000;
  38. X[0][3][6]=0.000000;    Y[0][3][6]=0.000000;
  39. X[0][3][7]=-1.000000;    Y[0][3][7]=0.000000;
  40. X[0][3][8]=0.000000;    Y[0][3][8]=0.000000;
  41. X[1][0][0]=-0.414214;    Y[1][0][0]=1.000000;
  42. X[1][0][1]=0.000000;    Y[1][0][1]=1.414214;
  43. X[1][0][2]=0.000000;    Y[1][0][2]=1.414214;
  44. X[1][0][3]=0.000000;    Y[1][0][3]=1.000000;
  45. X[1][1][0]=0.000000;    Y[1][1][0]=1.414214;
  46. X[1][1][1]=0.000000;    Y[1][1][1]=1.414214;
  47. X[1][1][2]=0.414214;    Y[1][1][2]=1.000000;
  48. X[1][1][3]=0.000000;    Y[1][1][3]=1.414214;
  49. X[1][1][4]=0.000000;    Y[1][1][4]=1.000000;
  50. X[1][1][5]=-0.707107;    Y[1][1][5]=0.707107;
  51. X[1][2][0]=-0.707107;    Y[1][2][0]=0.707107;
  52. X[1][2][1]=0.000000;    Y[1][2][1]=0.000000;
  53. X[1][2][2]=-0.414214;    Y[1][2][2]=1.000000;
  54. X[1][2][3]=0.000000;    Y[1][2][3]=0.000000;
  55. X[1][2][4]=0.000000;    Y[1][2][4]=0.000000;
  56. X[1][2][5]=0.000000;    Y[1][2][5]=0.000000;
  57. X[1][2][6]=0.000000;    Y[1][2][6]=0.000000;
  58. X[1][2][7]=0.000000;    Y[1][2][7]=1.000000;
  59. X[1][2][8]=0.000000;    Y[1][2][8]=0.000000;
  60. X[1][3][0]=0.000000;    Y[1][3][0]=0.000000;
  61. X[1][3][1]=0.707107;    Y[1][3][1]=0.707107;
  62. X[1][3][2]=0.000000;    Y[1][3][2]=0.000000;
  63. X[1][3][3]=0.000000;    Y[1][3][3]=0.000000;
  64. X[1][3][4]=0.414214;    Y[1][3][4]=1.000000;
  65. X[1][3][5]=0.000000;    Y[1][3][5]=0.000000;
  66. X[1][3][6]=0.000000;    Y[1][3][6]=0.000000;
  67. X[1][3][7]=0.000000;    Y[1][3][7]=1.000000;
  68. X[1][3][8]=0.000000;    Y[1][3][8]=0.000000;
  69. X[1][3][9]=0.000000;    Y[1][3][9]=0.000000;
  70. X[1][3][10]=0.000000;    Y[1][3][10]=0.000000;
  71. X[1][3][11]=0.000000;    Y[1][3][11]=0.000000;
  72. X[1][3][12]=0.000000;    Y[1][3][12]=0.000000;
  73. X[1][3][13]=0.000000;    Y[1][3][13]=0.000000;
  74. X[1][3][14]=0.000000;    Y[1][3][14]=0.000000;
  75. X[1][3][15]=0.000000;    Y[1][3][15]=0.000000;
  76. X[1][3][16]=-0.707107;    Y[1][3][16]=-0.707107;
  77.  
  78.  
  79.  
  80.  
  81. for (d=0;d<2;d++) {     
  82.      for (l=0;l<2;l++){
  83.          k=0;
  84.         for (i=0;i<17;i++){   
  85.           if (X[d][l][i] != X[d][l][i+1] && Y[d][l][i] !=Y[d][l][i+1]){
  86.              for (j=k;j<=k;j++){  
  87.                  R[d][l][j]=X[d][l][i];  
  88.          S[d][l][j]=Y[d][l][i];                
  89.                  printf ("[%d][%d][%d]\t%f\t%f\n",d,l,j,R[d][l][j],S[d][l][j]);  
  90.          if (R[d][l][j]>R[d][l][j+1] && S[d][l][j+1]){
  91.                    for (c=m;c<=m;c++){  
  92.                      P[d][l][c]=R[d][l][j];
  93.              Q[d][l][c]=S[d][l][j];
  94.                      printf ("[%d][%d][%d]\t%f\t%f\n",d,l,c,P[d][l][c],Q[d][l][c]);  
  95.                    }m++;
  96.                  }
  97.              }k++;
  98.           }
  99.          }
  100.         }
  101.      }
  102.  
  103.  
  104. getch ();
  105. }
  106.  
  107.  

I don't know why, but there are some arrays which are not eliminated even though the value are same.

Could you help me please?

Thank you
Apr 29 '09 #1
0 2151

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Robert | last post by:
Im a beginner in PHP and Im having a problem with this code. Im trying to remove duplicate elements from an array created via $_GET. I want users to be able to click on a link which sends an email...
1
by: gilgantic | last post by:
Is there anyway of eliminating duplicate entries as the database loads data using SQLLDR and/or .ctl (Control File)? I use the following command line using SQLLDR and a control file to load my...
3
by: Tony Young | last post by:
Hi, I have a multimap container. I want to eliminate all "duplicate" elements. By duplicate I mean something like (3, 4), (4, 3) and (4, 3), in which I want to eliminate any two of these...
3
by: Kay | last post by:
ABC ASF DFS ASS ABC <--- Duplicate JJK I want to store above char in an arry, but I'm not sure I'm right or not anyone can guide me or give me some suggestions, Thx?
2
by: Suma | last post by:
A newbie question : I have a vector of objects(pointers) . I have a function which overloads the less than operator . I can sort the objects without a problem. However when I pass the same...
4
by: sandi | last post by:
hi there i have fields name called .. PAF (text) , PNo (Number ) , LastName (Text) 2006/214/2 , 220101 , Winne 2006/321/3, 521496 , Joe 2006/321/1 , 521496 , Joe 2006/541/4 , 521496 ,...
4
by: comatose | last post by:
if I have an array of ten items how can I sort the first five items in the array without sorting the second five items?
4
by: Mokita | last post by:
Hello, I am working with Taverna to build a workflow. Taverna has a beanshell where I can program in java. I am having some problems in writing a script, where I want to eliminate the duplicates...
10
by: cmdolcet69 | last post by:
i need to find a way to look through my _ReadingArrayList3 and see if any number stored in the inarrayindex are duplicated. I need to first collect all the data and place it into the array, once the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.