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

Converting one-Dim array to two-Dim array

مغلق
بدأه نحلة نشيطة في 1 أبريل 2006 · 2 رد · 770 مشاهدة · في JavaSE
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

Asslam Alikoum ,

Every time I post in this forum I got no result I wonder why. Is it because my questions too silly t o answer or too dificult to .

This is my question this time hope it is worth to be answered:

If I have one dimensional array say array1[A*B]and I want to convert it into two dimensional array say array2[A] ... How to do that?

Is the following code is the right answer


{
for (int j=0; j< A*B; j++)
{
 for (int S=0; S< A*B; S++)
 {
  array2[j] = array1;
 }
}
}
for (int i=0; i< A*B; i++)

تم تعديل هذه المشاركة بواسطة نحلة نشيطة في 1 أبريل 2006 في 10:43

كما أريد أن أكون .. بأمر الله أكون

#2

I see that your code is wrong,, u will go out of boundary of arry2 ..;

try this code :

 for(int i=0;i<A,i++){
	for(int j=0;j<B;j++){
  array2[j] = array1[j + i*B];
	}
}

تم تعديل هذه المشاركة بواسطة malek_sa في 1 أبريل 2006 في 13:54

SCJP 5.0

#3

شكرا أخي مالك . سأجرب ما كتبته .

كما أريد أن أكون .. بأمر الله أكون

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

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