تبلیغات
دانلود سورس پروژه های مختلف برنامه نویسی، آموزش برنامه نویسی - سورس مرتب سازی یک آرایه با طول n با استفاده از Quick Sort
دانلود سورس پروژه های مختلف برنامه نویسی، آموزش برنامه نویسی
دانلود رایگان سورس پروژه
سایت برنامه نویسی تک کدر takcoder.ir


آموزش برنامه نویسی با استفاده از نوین ترین روش و ارائه پروژه های نمونه و مجموعه عظیم سورس کدهای آماده برای شما دوستان

مدیر سایت : Yahya Taherzadeh
نویسندگان
نظرسنجی
زبان برنامه نویسی مورد علاقه شما؟






اینم یه برنامه که ابتدا طول آرایه رو مشخص میکنید و سپس عناصر اونو از ورودی میگیره و با مرتب سازی سریع، به صورت صعودی مرتب میکنه و نمایش میده. 
#include<conio.h>
#include<iostream.h>

//--------------------------------------------------------------------------
void read_list(int a[],int n)
{
    int i;
    for(i=0;i<n;i++)
    {
        cout<<"\n ENTER THE ELEMENT ["<<i<<"] :: ";
        cin>>a[i];
    }
}
//--------------------------------------------------------------------------
void print_list(int a[],int n)
{
    int i;
    for(i=0;i<n;i++)
        cout<<a[i]<<"  ";
}
//--------------------------------------------------------------------------
void quick_sort(int a[],int first,int last)
{
    int low,high,temp,pivot;
    low=first;
    high=last;
    pivot=a[(first+last)/2];

    do{
        while(a[low]<pivot)
            low++;
        while(a[high]>pivot)
            high--;
        if(low<=high)
        {
            temp=a[low];
            a[low]=a[high];
            a[high]=temp;
            low=low+1;
            high=high-1;
        }
      }while(low<=high);

    if(first<high)
        quick_sort(a,first,high);
    if(low<last)
        quick_sort(a,low,last);
}
//--------------------------------------------------------------------------
void main()
{
    int a[20],n;

    //clrscr();
    cout<<"\nENTER THE ARRAY LENGTH :: ";
    cin>>n;

    read_list(a,n);

    cout<<"\nTHE ARRAY ELEMENTS ARE AS FOLLOWS :: ";
    print_list(a,n);

    quick_sort(a,0,n-1);

    cout<<"\nTHE SOTED LIST IS :: ";
    print_list(a,n);

cout<<"\n\n";
    getch();
}





نوع مطلب : آموزش، سی| سی پلاس پلاس، پروژه های تکمیل شده، 
برچسب ها : quick sort، مرتب سازی سریع، سورس مرتب سازی، آرایه، مرتب سازی آرایه ها، Sort، Array sort،
لینک های مرتبط :
Yahya Taherzadeh
جمعه 22 آذر 1392
سه شنبه 17 مرداد 1396 05:20 ق.ظ
I will immediately seize your rss feed as I can't in finding your email subscription link or
e-newsletter service. Do you've any? Please allow me realize so that I may
subscribe. Thanks.
سه شنبه 17 مرداد 1396 12:02 ق.ظ
Just want to say your article is as astounding. The clearness on your put
up is just nice and i can assume you're an expert in this subject.
Fine together with your permission let me to grasp your RSS feed to stay up to date with drawing close post.
Thanks one million and please keep up the enjoyable
work.
دوشنبه 16 مرداد 1396 06:43 ب.ظ
Hello there! This post could not be written much better!
Looking through this post reminds me of my previous roommate!
He continually kept preaching about this. I most certainly will send
this article to him. Fairly certain he's going to have a great
read. Thank you for sharing!
جمعه 6 مرداد 1396 08:16 ب.ظ
Spot on with this write-up, I actually think this site needs much more attention. I'll
probably be back again to read more, thanks for the info!
شنبه 17 تیر 1396 01:43 ب.ظ
If you desire to get a great deal from this post then you have to apply
these techniques to your won blog.
یکشنبه 11 تیر 1396 10:58 ق.ظ
First off I want to say excellent blog! I had a quick question which I'd like to ask if you
don't mind. I was interested to find out how you center yourself and clear your mind before writing.

I've had a difficult time clearing my mind in getting my thoughts out there.

I do take pleasure in writing however it just seems like the first 10
to 15 minutes tend to be wasted just trying to figure out
how to begin. Any suggestions or hints?
Thanks!
جمعه 29 اردیبهشت 1396 01:19 ق.ظ
Spot on with this write-up, I absolutely feel this site needs much more attention. I'll probably be returning to see more,
thanks for the advice!
جمعه 15 اردیبهشت 1396 10:39 ب.ظ
The other day, while I was at work, my sister stole
my iphone and tested to see if it can survive a thirty foot drop, just so she can be a youtube sensation. My iPad
is now destroyed and she has 83 views. I know this is entirely off topic
but I had to share it with someone!
چهارشنبه 30 فروردین 1396 08:07 ب.ظ
Great blog! Do you have any tips and hints for aspiring writers?
I'm hoping to start my own website soon but I'm a little lost on everything.
Would you recommend starting with a free platform like Wordpress or go for a paid option? There are so
many options out there that I'm totally confused ..
Any ideas? Thank you!
جمعه 25 فروردین 1396 07:36 ب.ظ
Hello there! I could have sworn I've been to this website before but after checking through some of the post I
realized it's new to me. Nonetheless, I'm definitely happy
I found it and I'll be book-marking and checking back frequently!
جمعه 18 فروردین 1396 05:17 ب.ظ
You can definitely see your enthusiasm in the article you
write. The arena hopes for even more passionate writers like you who aren't afraid to say how they believe.
All the time follow your heart.
 
لبخندناراحتچشمک
نیشخندبغلسوال
قلبخجالتزبان
ماچتعجبعصبانی
عینکشیطانگریه
خندهقهقههخداحافظ
سبزقهرهورا
دستگلتفکر




صفحات جانبی
آمار وبلاگ
تاییدیه پرداخت
تبلیغات
به سایت تک کدر خوش آمدید