This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#include <utility> | |
// | |
// Quick sort for single linked list | |
// | |
// Template arguments: | |
// T: node's pointer type | |
// Next: function/functor to get next node | |
// Compare: functor to compare 2 arguments | |
// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <algorithm> | |
#include <stdint.h> | |
#include <string> | |
#include <map> | |
#include <cassert> | |
using namespace std; | |
// ip range is expressed as [startIP, endIP) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <windows.h> | |
#include <Tlhelp32.h> | |
int _tmain(int argc, const TCHAR* argv[]) | |
{ | |
if(argc != 2) return -1; | |
TCHAR* processName = argv[1]; | |
PROCESSENTRY32 ppe = {0}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
LONGLONG GetFrequency() | |
{ | |
LARGE_INTEGER qpFrequency; | |
::QueryPerformanceFrequency(&qpFrequency); | |
return qpFrequency.QuadPart; | |
} | |
double Tick() | |
{ | |
static LONGLONG llFrequency = GetFrequency(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int ExecuteCommand(const TCHAR* commandLine) | |
{ | |
STARTUPINFO si; | |
PROCESS_INFORMATION pi; | |
BOOL bRet; | |
DWORD lpExitCode; | |
memset(&si, 0, sizeof(si)); | |
si.cb = sizeof(si); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
HANDLE GetProcessByName(const TCHAR* szProcessName) | |
{ | |
if(szProcessName == NULL) return NULL; | |
CString strProcessName = szProcessName; | |
DWORD aProcesses[1024], cbNeeded, cProcesses; | |
if ( !EnumProcesses( aProcesses, sizeof(aProcesses), &cbNeeded ) ) | |
return NULL; | |
// Calculate how many process identifiers were returned. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if(has("win32") || has("win95") || has("win64") || has("win16")) "判定当前操作系统类型 | |
let g:iswindows=1 | |
else | |
let g:iswindows=0 | |
endif | |
set nocompatible "不要vim模仿vi模式,建议设置,否则会有很多不兼容的问题 | |
syntax on"打开高亮 | |
if has("autocmd") | |
filetype plugin indent on "根据文件进行缩进 | |
augroup vimrcEx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
void merge(int* input, int* left, int nLeft, int* right, int nRight) | |
{ | |
int i = 0; | |
// copy until one array ends | |
int l = 0, r = 0; | |
while(l < nLeft && r < nRight) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--Bubble Sort | |
-- 1, 3, 2, 7 | |
function bubble_sort(arr) | |
for i=table.getn(arr), 2, -1 do -- each loop put one element in right position, decrease! | |
for j=2, i do -- inside the loop, do the exchange one by one | |
if arr[j] < arr[j-1] then | |
tmp = arr[j-1] | |
arr[j-1] = arr[j] | |
arr[j] = tmp | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# sleep sort!!! | |
use strict; | |
use Thread; | |
my @threads; | |
my $count = 0; | |
foreach my $n (@ARGV) { |
OlderNewer