Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Finding common elements between arrays and storing them

$
0
0
Hello i'm a c++ beginner and i'm stuck at this, so long i've been using this code
 int sizeA1=sizeof(array1[3])/sizeof(array1[0]);
int sizeA2=sizeof(array2[3])/sizeof(array2[0]);
int sizeA3=sizeof(array3[3])/sizeof(array3[0]);

for (int i=0; i < sizeA1; i++)
		   {
			for (int j = 0; j < sizeA3; j++)
			 {
			   if(array1[i]==array3[j])
				newarray2[m]=array1[i];
				Memo4->Lines->Add(IntToStr(newarray2[m]));

			 }
		   } 


I don't know where the miskate is, the memo displays 0, but it should display de common element between two arrays (i know there is one because i have the arrays displayed in another 2 memos)

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>