Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as C++ by 456 ( 14 years ago )
// Sortirovki.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "string.h"
#include <iostream>
#include "sort.h"
#include <time.h>
#include "memory.h"
using namespace std;

#define N 5000
#define BEGIN 1000

int _tmain(int argc, _TCHAR* argv[])
{
 int k[N], f[N];
 clock_t t1, t2;
 GetRandKey (1);
 for (int i=0; i<N; i++)  f[i]=GetRandKey(0);
 for (int n = BEGIN; n<=N; n+=BEGIN)
 {
  cout <<"\n=========" <<n <<"==========" << endl;
  cout << "SortRaspred";   //Распределяющая сортировка
  memcpy(k,f,n*sizeof(int));
  t1 = clock();
  int SA = SortRaspred(k, n);
  t2 = clock();
  cout <<ends <<(double)(t2-t1)/CLOCKS_PER_SEC <<ends << ends;

  cout <<"\n=========" <<n <<"==========" << endl;
  cout << "SortBystr";     //"Быстрая"  сортировка 
  memcpy(k,f,n*sizeof(int));
  t1 = clock();
     int SE = SortBystr(k,0,n-1);
  t2 = clock();
  cout <<ends <<(double)(t2-t1)/CLOCKS_PER_SEC <<ends << ends;

  cout <<"\n=========" <<n <<"==========" << endl;
  cout << "SortPrVybora";   //Сортировка  выбором.
  memcpy(k,f,n*sizeof(int));
  t1 = clock();
  int SB = SortPrVybora(k, n);
  t2 = clock();
  cout <<ends <<(double)(t2-t1)/CLOCKS_PER_SEC <<ends << ends;

  cout <<"\n=========" <<n <<"==========" << endl;
  cout << "SortPuz";  //Сортировка методом "пузырька"
  memcpy(k,f,n*sizeof(int));
  t1 = clock();
  int SC = SortPuz(k, n);
  t2 = clock();
  cout <<ends <<(double)(t2-t1)/CLOCKS_PER_SEC <<ends << ends;

  cout <<"\n=========" <<n <<"==========" << endl;
  cout << "SortSheiker";   //Шейкер-сортировка. 
  memcpy(k,f,n*sizeof(int));
  t1 = clock();
  int SD = SortSheiker(k, n);
  t2 = clock();
  cout <<ends <<(double)(t2-t1)/CLOCKS_PER_SEC <<ends << ends;

  

  cout <<"\n=========" <<n <<"==========" << endl;
  cout << "SortCikl";  //Сортировка   циклическим   слиянием
  memcpy(k,f,n*sizeof(int));
  t1 = clock();
     SortCikl(k , n);
  t2 = clock();
  cout <<ends <<(double)(t2-t1)/CLOCKS_PER_SEC <<ends << ends;
 }
 return 0;
}

 

Revise this Paste

Your Name: Code Language: