ZZZ的最后突袭!

ZZZ的最后突袭!

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
#include <vector> #include <iostream> #include <string> #include "time.h" using namespace std; void construct(vector< int > &values, int size); void construct( int values[], int size); void mergesort(vector< int >& values); void mergesort( int low, int high, vector< int int >& scratch); void merge( int low, int mid, int high, vector< int int >& scratch); void mergesort( int values[], const int size); void mergesort( int low, int high, int values[], int scratch[]); void merge( int low, int mid, int high, int values[], int scratch[]); void quickSort( int values[], int left, int right); void quickSort(vector< int >& values, int left, int right); int main(){ clock_t start; clock_t finish; const int sizea = 32000; //CHANGE # OF ELEMENT HERE!! const int sizeb = 64000; const int sizec = 128000; vector< int > values_vec; int values_array1[sizea]; int values_array2[sizeb]; int values_array3[sizec]; cout<< "=====sorting for VECTOR=====" <<endl; // for(unsigned int i=0; i<values_vec.size(); ++i) // cout<< i <<": "<<values_vec[i]<<endl; // cout<<endl; construct(values_vec, sizea); start = clock(); mergesort(values_vec); finish = clock(); // for(unsigned int i=0; i<values_vec.size(); ++i) // cout<< i <<": "<<values_vec[i]<<endl; cout << "Merge Sort Vector 32000 " << (( double )(finish-start))/CLOCKS_PER_SEC << " seconds." << endl; construct(values_vec, sizeb); start = clock(); mergesort(values_vec); finish = clock(); // for(unsigned int i=0; i<values_vec.size(); ++i) // cout<< i <<": "<<values_vec[i]<<endl; cout << "Merge Sort Vector 64000 " << (( double )(finish-start))/CLOCKS_PER_SEC << " seconds." << endl; construct(values_vec, sizec); start = clock(); mergesort(values_vec); finish = clock(); // for(unsigned int i=0; i<values_vec.size(); ++i) // cout<< i <<": "<<values_vec[i]<<endl; cout << "Merge Sort Vector 128000 " << (( double )(finish-start))/CLOCKS_PER_SEC << " seconds." << endl;
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
// for(unsigned int i=0; i<values_vec.size(); ++i)
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 5

ZZZ&ccedil;š„&aelig;œ€&aring;Ž&ccedil;&ordf;&egrave;&cent;&shy;&iuml;&frac14;

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online