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
void hanoi(int n ,char source, char dest, char mid) | |
{ | |
if (n == 1) { | |
// 如果 n = 1, 那么可以直接从source 挪到 dest | |
printf("%d from %c to %c\n",n,source,dest); | |
} else { | |
// 上面的n-1个,先放到作为缓冲的那个柱子上,好把最下面一个给移开 | |
hanoi(n-1, source, mid, dest); |
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
/************************************************************************* | |
> File Name: binary_tree.cpp | |
> Author: | |
> Mail: | |
> Created Time: 2016年11月03日 星期四 21时50分39秒 | |
************************************************************************/ | |
#include<iostream> | |
using namespace std; | |
#include <stack> |
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 <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <stddef.h> | |
#define MAX 64 | |
typedef char elem_t; | |
typedef struct node_t { | |
elem_t element; | |
struct node_t *left; | |
struct node_t *right; |
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 <stdio.h> | |
#include <stdlib.h> | |
#define MinPQSize 5 | |
#define MinData -10000 | |
struct HeapStruct; | |
typedef struct HeapStruct *priorityQueue; | |
typedef int ElementType; | |
priorityQueue initialize(int elementsNum); | |
void destroy(priorityQueue H); | |
void makeEmpty(priorityQueue H); |
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
void bubbleSort(int array[],int n) { | |
int i,j,tmp; | |
for(i = 0;i < n;i++) { | |
for(j = 0;j < n-i;j++ ) { | |
if (array[j] > array[j+1]) { | |
tmp = array[j]; | |
array[j] = array[j+1]; | |
array[j+1] = tmp; | |
} | |
} |
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 <stdio.h> | |
#include <string.h> | |
#include <stdlib.h> | |
int T,n,m; | |
#define maxn 1005 | |
#define maxm 52 | |
char DNA[maxm][maxn]; | |
char s[maxn]; | |
void processDNA() { | |
int count[maxn][4] = {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
bool YV12ToBGR24_Native(unsigned char* pYUV, unsigned char* pBGR24, int width, int height) { | |
if (width < 1 || height < 1 || pYUV == NULL || pBGR24 == NULL) | |
return false; | |
const long len = width * height; | |
unsigned char* yData = pYUV; | |
unsigned char* vData = &yData[len]; | |
unsigned char* uData = &vData[len >> 2]; | |
int bgr[3]; | |
int yIdx, uIdx, vIdx, idx; |
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
void yuv420_to_argb8888(uint8_t *pYUV, | |
uint32_t sy, uint32_t suv, | |
int width, int height, | |
uint32_t *rgb, uint32_t srgb) { | |
uint8_t *yp; | |
uint8_t *up; | |
uint8_t *vp; | |
yp = pYUV; | |
up = pYUV + width*height; | |
vp = up + width*height / 4; |
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
void rbga32_to_rgb24_ssse3(uint8_t* dst, uint32_t* src, int width, int height) { | |
__m128i *d = (__m128i*)dst; | |
__m128i *s = (__m128i*)src; | |
__m128i mask = _mm_setr_epi8(0, 1, 2, 4, 5, 6, 8, 9, 10, 12, 13, 14, -1, -1, -1, -1); | |
for (int i = 0; i < width*height; i += 16) { | |
__m128i sa = _mm_shuffle_epi8(_mm_load_si128(s), mask); | |
__m128i sb = _mm_shuffle_epi8(_mm_load_si128(s + 1), mask); | |
__m128i sc = _mm_shuffle_epi8(_mm_load_si128(s + 2), mask); | |
__m128i sd = _mm_shuffle_epi8(_mm_load_si128(s + 3), mask); |
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 <iostream> | |
#include <cstddef> | |
#include <queue> | |
#include <string> | |
#include <cstdlib> | |
#include <stack> | |
using namespace std; | |
class Node { | |
public: | |
int data; |