الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

region-merging algorithm

مغلق
بدأه oskar في 4 يناير 2006 · 1 رد · 496 مشاهدة · في Microsoft Visual C#.NET
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم

معلش بدي خوارزميه ل

region-merging

؟؟؟؟؟؟؟

ممكن تساعدوني ياجماعه

#2

بسم الله الرحمن الرحيم

السلام عليكم

هل أنت تقصد عمل Merge between two sorted array ؟؟؟؟

أدى كود بسيط لعملية الMerge بالسى بلس بلس

template<class T>
void Array<T>::Merge(Array<T>const& array)
{
 //Get new length subtracted from nuber of identical numbers in the two arrays
 int Repeated  = (this->GetRepeatedNum(array) );
 int newLength =  (Length() + array.Length()) - Repeated;
 T* newData = new T[ newLength ];                   //Allocate new array with sepecific size
 int i = 0 , j = 0 , k = 0; //Define three elements

 while( i < Length() && j < array.Length() ) //To Walk in the two array
 {
  if(data < array.data[j]) //Store List1 element in newData then get the next element in List1
   newData[k++] = data;

  else
  if(data > array.data[j])  //Store List2 element in newData then get the next element in List2
   newData[k++] = array.data[j++];

  else        //if data == array.data[j] get one of them then get the next element in List1 and List2
  {
   newData[k++] = data[i++];
   j++;
  }

 }

أعتذر جدا بسبب وضعى للكود بلسى بلس بس سهل جدا أنك تحولة الى سى شارب :)

Muhammad Allam

Computer Science

@Resource(MappedURL="My Blog" )

هذا الموضوع مغلق.

مواضيع مشابهة