- 冒泡排序
- 快速排序
- 直接插入排序
- 希尔排序
- 简单选择排序
- 桶排序
- 归并排序
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
//std headers | |
#include <fstream> | |
#include <iostream> | |
//lib headers | |
#include <gif_lib.h> | |
#define USING_NEW_GIF_LIB defined(GIFLIB_MAJOR) && GIFLIB_MAJOR >= 5 | |
cv::Mat imread_gif(const std::string& filename, const int flags) | |
{ | |
std::ifstream stream(filename, std::ios::in | std::ios::binary); |
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
#coding: utf-8 | |
#demo of beam search for seq2seq model | |
import numpy as np | |
import random | |
vocab = { | |
0: 'a', | |
1: 'b', | |
2: 'c', | |
3: 'd', |
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
static const std::string base64_chars = | |
"ABCDEFGHIJKLMNOPQRSTUVWXYZ" | |
"abcdefghijklmnopqrstuvwxyz" | |
"0123456789+/"; | |
static inline bool is_base64(unsigned char c) { | |
return (isalnum(c) || (c == '+') || (c == '/')); | |
} |
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 <vector> | |
#include <string> | |
#include <algorithm> | |
#include <sstream> | |
#include "dirent.h" | |
std::string replace_all(const std::string& str, const std::string& from, const std::string& to) { | |
std::string result_str = str; | |
size_t start_pos = 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
#coding:utf-8 | |
import numpy as np | |
import matplotlib.pyplot as plt | |
import math | |
def f(x): | |
return x[0] * x[0] + 50 * x[1] * x[1] | |
def g(x): | |
return np.array([2 * x[0], 100 * x[1]]) |
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
static std::string strip(const std::string& content) | |
{ | |
if (content.empty()) | |
{ | |
return content; | |
} | |
std::string result = content; | |
while (true) | |
{ | |
const wchar_t last_char = result[result.size() - 1]; |
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> | |
#include <cstring> | |
// FreeType headers | |
#include <ft2build.h> | |
#include FT_FREETYPE_H | |
// OpenCV headers | |
#include <opencv2/core/core.hpp> |
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 <fstream> | |
static std::string convertUtf16ToLocal(const unsigned short data) | |
{ | |
char dstData[3]; | |
::wcstombs(dstData, (const wchar_t *)&data, 2); | |
dstData[2] = '\0'; | |
return dstData; | |
} | |
static void dumpUtf16Charset() |