473,785 Members | 2,576 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to sort array and eliminate duplicate array?

16 New Member
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 2172

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

Similar topics

4
13842
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 address to an array. I just want to remove duplicate email addresses from the array. Ive tried array_unique() on my test server but it doesnt work. So i tried to remove duplicates myself before storing them into the array. The script works...
1
10352
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 data, but the sample.dat file has duplicate information. I would like to be able to eliminate this, since I have know ability to manipulate the sample.dat. ${ORACLE_HOME}/bin/sqlldr $USERPW /home/sample/sample.ctl ############# sample.ctl...
3
3158
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 three. The most straightforward way I can think of is to first swap every member such that every member has its key smaller than its value. Then loop thru the multipmap and erase duplicates (please see the loop below). Is there a more automatic way...
3
1815
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
5624
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 function as an arg to the unique function, I still see the duplicate objects. Shouldnt unique be aple to operate with just the less_than overload- since if both the predicates constant1 < constant2 and constan2 < constant1 return false implies...
4
1528
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 , Joe
4
1886
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
13969
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 in an array (String). for (int k=0; k<myLength; k++){ boolean isthere=false; for (int l=0; l<sizeres; l++){ if (res.equals(my)){
10
4139
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 array is filled i call my sort SortArray() Sub that will look at every arrayindex in the _ReadingArrayList3, at this time after that i can;t seem to find out how to compare values in the array. Below is the code i have been working on. Thanks ...
0
9647
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10161
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10098
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9958
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7506
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6743
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5390
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4058
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2890
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.