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

مساعدة في داله ترتيب الارقام وقت الادخال تصاعدي

بدأه توتـآ في 14 مارس 2010 · 2 رد · 4,834 مشاهدة · في C++.Net
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

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

أحتاج مساعدة

في إني سأستقبل من اليوز عدة ارقام

مثلا ً 9 و 3 و 1

هذي الارقام سوف أضيفها في Array موجودة لدي لكن سأرتبها تصاعدي

مثلا ً الـ Array كانت 10 , 6 , 4, 2

عند طباعتها سوف تكون

10 , 9 , 6 , 4 , 3 , 2 , 1

هذي محاولتي ....

void LinkThem(   int R[ ] ,    int L[ ] ,    int Max)  

{

      int i,             // the index of the next Request to be placed in list.

            j,            // the index used to find the correct place in the list.

      Prevj;          // the previous value of j.

      L[0] = 1;      // the previous value of j.

      L[1] = 0;      // initialize the linked list for the first request.



      // R is the next request to be placed in the list

      for(i = 2; i <= Max - 1; i = i + 1)

      {

            Prevj = 0;

            // find the index j where L should point.

            for(j = L[Prevj]; j != 0; j = L[j])


      // R is the next request to be placed in the list

      for(i = 2; i <= Max - 1; i = i + 1)

      {

            Prevj = 0;

            // find the index j where L should point.

            for(j = L[Prevj]; j != 0; j = L[j])



                  if(R < R[j])

                  {

                        // found the place to insert L in the list.

                        cout << "Inserting \n";

                        L[Prevj] = i;

                        L = j;

                        // get the next request to be added to the list.



                  }
#2
# include <iostream>
using namespace std;
void bubblesort(int list[], int size)
{
	int i,j;
	int temp;

	for(i=0;i<size-1;i++)
	{
		for(j=0;j<size-i-1;j++)
			if(list[j]> list[j+1])

			{
				temp=list[j];
				list[j]=list[j+1];
				list[j+1]=temp;
			}
	}
}

int main()
{
	int list[10];

	int i,j;

	cout<<"enter the numbers:";

	for(j=0;j<10;j++)
		cin>>list[j];

	bubblesort(list,10);

	cout<<"after sorting, the list elements are:"<<endl;

	for(i=0;i<10;i++)
		cout<<list<<"  ";

		cout<<endl;

	return 0;
}
#3

شكرا ً الله يجزاك ِ خير (L)

1

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

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

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

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

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