[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/yangxt225/sort/master/insertSort.cpp [Back]  [Original]

// :
// 
#include 
#include 
#include 
#include  // sleep(3);

std::ifstream fin("data.in");
std::ofstream fout("data.out");

#define MAX 1024*1024
// ,,O(n^2)
void insertSort(int array[], int num)
{
	for(int i=1; i=0; --j)
		{
			if(value < array[j])
			{
				array[j+1] = array[j]; // 
			}
			else
				break;
		}
		array[j+1] = value;
	}
}

long getCurrentTime()    
{    
   struct timeval tv;    
   gettimeofday(&tv,NULL);    
   return tv.tv_sec * 1000 + tv.tv_usec / 1000;    
} 

int main()
{
	int array[MAX];
	int num = 0;
	while(fin >> array[num])
		++num;

	long start = getCurrentTime();
	std::cout 

Web Proxy Viewer  |  New URL  |  Original Page