This file contains hidden or 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 <algorithm> | |
| #include <fstream> | |
| #include <iostream> | |
| #include <string> | |
| #include <vector> | |
| using namespace std; | |
| bool covered(const vector<string>& filters, const string& line) | |
| { |
This file contains hidden or 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
| 排列的问题,求一个集合元素的全排列。 | |
| 整数集合s和一个整数sum,求集合s的所有子集su,使得su的元素之和为sum | |
| 1 #include <iostream> | |
| 2 | |
| 3 using namespace std; | |
| 4 | |
| 5 |
This file contains hidden or 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
| // | |
| struct node { | |
| int data; | |
| struct node* next; | |
| }; | |
| void Push(struct node** headRef, int newData){ | |
| struct node* new_node = (struct node*)malloc(sizeof(struct node)); | |
| new_node->data = newData; |
This file contains hidden or 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
| #ifndef __SKIPLIST_H | |
| #define __SKIPLIST_H | |
| #define SKIPLIST_MAXLEVEL 8 | |
| typedef struct skiplistNode { | |
| double score; | |
| struct skiplistNode *backward; | |
| struct skiplistLevel { | |
| struct skiplistNode *forward; |
This file contains hidden or 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
| //For sparse matrix | |
| typedef struct QLNode | |
| { | |
| int iPos, jPos; //非零元素的行列下标; | |
| int iElem; //元素; | |
| struct QLNode *right, *down; | |
| }QLNode; | |
| typedef struct QLNode* QLink; |
This file contains hidden or 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
| 34 void insertSort(int a[], int len){ | |
| 35 for (int j = 1; j < len; ++j){ | |
| 36 int key = a[j]; | |
| 37 int i = j - 1; | |
| 38 while(i >= 0 && a[i] > key){ | |
| 39 a[i+1] = a[i]; | |
| 40 i--; | |
| 41 } | |
| 42 a[i+1] = key; | |
| 43 } |
This file contains hidden or 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
| /* | |
| * @func: find the ascends element from array | |
| * @params: arr{array}, the given array, | |
| * len{int}, the length of array | |
| * pos{int}, the first position that finding the ascending elements | |
| */ | |
| 43 void findAscend_(int arr[], int len, int pos){ | |
| 44 int index_array[ARRLEN] = {0}; | |
| 45 int current_max = 0; | |
| 46 int current_max_index = 0; |
This file contains hidden or 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 | |
| binary_search_first_position(int *A, int n, int target) { | |
| int end[2] = { -1, n }; | |
| while (end[0] + 1 < end[1]) { | |
| int mid = (end[0] + end[1]) / 2; | |
| int sign = (unsigned)(A[mid] - target) >> 31; | |
| end[1-sign] = mid; | |
| } | |
| int high = end[1]; | |
| if (high >= n || A[high] != target) |
This file contains hidden or 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
| # EDIT: 2013/10/20 | |
| # google has updated its kwt UI, this script doesn't work any more! | |
| # may be I will update this script when I have time to investigate their new Interface. | |
| from selenium import webdriver | |
| from selenium.common.exceptions import TimeoutException | |
| import selenium.webdriver.support.wait | |
| selenium.webdriver.support.wait.POLL_FREQUENCY = 0.05 | |
| import re |
This file contains hidden or 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
| // EDIT: 2013/10/20 | |
| // google has updated its kwt UI, this script doesn't work any more! | |
| // may be I will update this script when I have time to investigate their new Interface. | |
| // requires | |
| var utils = require('utils'); | |
| var casper = require('casper').create() | |
| var casper = require('casper').create({ | |
| verbose: true, |