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

أريد مساعد في كتابة كود باستخدام C++ To Merging Two Arrays

بدأه qassim313 في 21 يونيو 2009 · 4 رد · 985 مشاهدة · في الأسئلة المجابة
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

أريد مساعد في كتابة كود باستخدامc++ to merging two arrays

أود مساعدتي في كتابة كود باستخدام c++ ويعمل دمج merging لمجموعتين والمحصلة output تكون الأرقام مترتبة حسب ترتيبها العددي 1,2,3,4,5,6,7,8,9,10

FIRST ARRAY a[ 5]={3, 4, 6, 7, 9

};

SECOND ARRAY b[4 ]={2, 1 , 5, 8.10

;{

#2

انشئ مصفوفة جديد مساوية لحجم المصفوفتين و انسخ كل العناصر فيها ثم طبق أي خورازمية ترتيب ، مثلا Bubble Sort

[color= #0000ff;]void bubbleSort[color= #000000;]([color= #0000ff;]int a[color= #000000;][[color= #000000;]],[color= #0000ff;]int m[color= #000000;])

[color= #000000;]{

	[color= #0000ff;]for[color= #000000;]([color= #0000ff;]int i[color= #000000;]=[color= #ff0000;]0;i[color= #000000;]<m;[color= #000000;]++i[color= #000000;])

		[color= #0000ff;]for[color= #000000;]([color= #0000ff;]int j[color= #000000;]=[color= #ff0000;]0;j[color= #000000;]<m[color= #ff0000;]-1;[color= #000000;]++j[color= #000000;])

			[color= #0000ff;]if[color= #000000;]( a[color= #000000;][j[color= #000000;]] [color= #000000;]> a[color= #000000;][j[color= #ff0000;]+1[color= #000000;]] [color= #000000;])

			 [color= #000000;]{

				[color= #007f00;]// swap it.

			 [color= #000000;]}

[color= #000000;]}

حل اخر هو بانشاء مصفوفة جديدة وادخال عناصر المصفوفة الاولى بعد ترتيبها ، ثم ادخال عناصر المصفوفة الثانية في المكان الصحيح.

بالتوفيق.

#3

شكرا أخي الكريم والفاضل ولكن لم افهم يا ريت لو تتفضل وتكتب الكود كامل بوضع الارقام فيه!

وهل هذا البرنامج باستخدام c# صحيح

using System;

public class ReverseArraySort

{

public static void Main()

{

string[] strings = {"3", "4", "6", "7", "9", "2, "1" , "5", "8","10"};

Console.WriteLine ("Array elements: ");

DisplayArray (strings);

Array.Sort (strings); // Sort elements

DisplayArray (strings);

}

public static void DisplayArray (Array array)

{

foreach (object o in array)

{

Console.Write ("{0} ", o);

}

Console.WriteLine();

}

}

تم تعديل هذه المشاركة بواسطة qassim313 في 22 يونيو 2009 في 15:56

#4

try this solution ...

#include<iostream>

using namespace std;

int main()
{
	int a[5]={3, 4, 6, 7, 9 };
	int b[5]={2, 1, 5, 8, 10};
	int c[10];


	for(int i=0;i<10; i++)
	{
		if(i<=4)
			c=a;
		else
			c=b[i-5];
	}




int index;
int i=0;
int min,j;
	for(;i<9; i++)
	{
		min=c;
		j=i+1;

		for(; j<10; j++)
				if(c[j]<min)
		{
			min=c[j];
			index=j;

		}

				c[index]=c;
				c=min;


	}



	for(int i=0; i<10; i++)
		cout<<c<<' ';


		return 0;
}
#5

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

السلام عليكــم ورحمـة الله وبركاتــه


#include <iomanip.h>
int main()
{
// constant variable can be used to specify array size
const int arraySize = 10;
int s[ arraySize ]; // array s has 10 elements
for ( int i = 0; i < arraySize; i++ )//set values
s[ i ] = 2 + 2 * i;
cout << "Element" << setw( 13 ) << "Value" << endl;
// output contents of array s in tabular format
for ( int j = 0; j < arraySize; j++ )
cout << setw( 7 )<<j<< setw(13)<<s[j] << endl;
return 0; // indicates successful termination
} // end main
 #include <iostream.h>

اما هذا فهو مصفوفة من بعد واحد one dimensional array

_____________________________________________________________________


</p>
<p style="margin-bottom: 0in;">int main()</p> <p style="margin-bottom: 0in;">{ </p> <p style="margin-bottom: 0in;"> const int nr=3, nc=5;</p> <p style="margin-bottom: 0in;"> int tab[nr][nc]={{84,87,54,88,74}, {76,77,94,30,91}, {85,88,86,100,99}};</p>
<p style="margin-bottom: 0in;"> <meta http-equiv="CONTENT-TYPE" content="text/html; charset=utf-8"> <title></title> <meta name="GENERATOR" content="OpenOffice.org 3.0 (Unix)"> <style type="text/css"> </style> <p style="margin-bottom: 0in;">return 0;</p> <p style="margin-bottom: 0in;">}</p> </p>
	   	<meta http-equiv="CONTENT-TYPE" content="text/html; charset=utf-8">	  <title></title>	  <meta name="GENERATOR" content="OpenOffice.org 3.0  (Unix)">	  <style type="text/css">			</style>	<p style="margin-bottom: 0in;">#include <iostream.h></p>  <p style="margin-bottom: 0in;">#include <iomanip.h></p>  <p style="margin-bottom: 0in;">

while this one is 2 dimentional array ,like a table with rows and columns .................

اما هذه فهي من بعدين تتألف من افقيا و عاموديا

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

عدد الزوار حالياً

المتواجدون خلال آخر دقيقتين · يتحدّث كل ٣٠ ثانية

—الإجمالي—أعضاء مسجّلون—زوار بدون تسجيل

جارٍ التحقق من المتواجدين…