صفحه 1 از 1

انالیز زمانی چند تا مرتب سازی

ارسال شده: جمعه ۶ دی ۱۳۹۲, ۱۲:۳۳ ب.ظ
توسط shidee
سلام دوستان
پروژه ای که مشغول انجامش هستم باید این خروجی رو به من تحویل بده:
زمان اجرای انواع مرتب سازی ها برای ارایه هایی با طول های مختلف
برنامه درست اجرا میشه اما ارور اور فلو شدن استک رو میده
ممکنه یه راهنمایی کنید ببینم مشکل از کجاست؟
 
#include <iostream>
#include <cstdlib>
#include <ctime>
#include <time.h>
#include <stdio.h>
#include <sys\timeb.h>
#include <dos.h>
using namespace std;    selection_sort (int arr[],int n)  {  //time_t t = time(0);  //struct tm *now = localtime(&t);   timeb t1, t2;   long d;   ftime(&t1);   register int i , j ;   int max , temp ;   for (i=n-1;i>0;i--)   {   max = 0 ;   for (j=1;j<=i;j++)   if (arr[max]<arr[j])   max=j ;   temp=arr[i] ;   arr[i]=arr[max] ;   arr[max]=temp ;   }   ftime(&t2);   d = (t2.time - t1.time) * 1000L + ( t2.millitm - t1.millitm );   printf("Time elapsed is %ld miliseconds\n", d);  //time_t t2 = time(0);  //struct tm *now2 = localtime(&t2);  //cout<<difftime(t2,t);  } 


int main()
{

int e[100], a[1000], b[10000] , c[100000] , d[1000000];
for(int i=0;i<100;i++)
{
e[i]=rand();
}
for(int i=0;i<1000;i++)
{
a[i]=rand();
}
for(int i=0;i<10000;i++)
{
b[i]=rand();
}

for(int i=0;i<100000;i++)
{
c[i]=rand();
}

for(int i=0;i<1000000;i++)
{
d[i]=rand();
}
cout<<"the time of running bubble sort for e is:";
selection_sort (e,100);
cout<<"the time of running bubble sort for a is:";
selection_sort (a,1000);
cout<<"the time of running bubble sort for b is:";
selection_sort (b,10000 );
cout<<"the time of running bubble sort for c is:";
selection_sort (c,100000 );
cout<<"the time of running bubble sort for d is:";
selection_sort (d,1000000 );



getchar();
return 0;
}