自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(13)
  • 资源 (6)
  • 收藏
  • 关注

原创 深度优先+回溯法生成随机迷宫

如题,迷宫效果:#include #include #include #include "time.h"#include "stdlib.h"using namespace std;class MazeCell {public: bool right, down; bool visited; int x, y; MazeCell() : x(0), y(

2013-11-13 14:04:55 1473

原创 C++ 并查集模板:找矩阵中'0'区域的个数

#include "time.h"#include #include #include using namespace std;template class UnionFind {private: map parent;public: void Union(T x, T y) { map::iterator i; T px = Find(x); T py = F

2013-10-22 08:08:12 1664

原创 C++ LRU Cache

#include #include #include using namespace std;template class LRUNode {public: Key key; Value value; class LRUNode *prev, *next; LRUNode() : prev(NULL), next(NULL) {} LRUNode(Key k, Value

2013-10-20 16:38:56 952

原创 [GeeksforGeeks]Remove all adjacent duplicates

Given a string, recursively remove adjacent duplicate characters from string. The output string should not have any adjacent duplicates.Input:  azxxzyOutput: ayFirst "azxxzy" is reduced to "az

2013-10-17 13:20:41 2898

原创 [LeetCode]String to Integer

class Solution {public: int atoi(const char *str) { // Note: The Solution object is instantiated only once and is reused by each test case./* * input: space, sign, digits, int limit */

2013-10-11 02:52:59 809

原创 自己编写的80x86虚拟机 NXVM

发一款自己写的80x86虚拟机 NXVM【简介】这个虚拟机是用C编写的,一共37,000行代码。它完整的模拟了一台PC,包括一个80386 CPU,以及所有必要的设备,例如内存、DMA、中断控制器、软驱、硬盘、键盘、显示器等。因此,它可以运行一个基于x86的操作系统,如MS-DOS6.22。NXVM虚拟机可以同时在Windows和Linux下通过编译。在Wind

2013-10-10 04:15:57 6206 3

原创 [LeetCode]Reverse Integer

这题啥也不说了,简单…… 记一下代码。要通过测试,主要就是处理一下正负号。class Solution {public: int reverse(int x) { // Note: The Solution object is instantiated only once and is reused by each test case.

2013-10-10 02:39:48 741

原创 [LeetCode]ZigZag Conversion

这题没什么意思,就是纯粹的找规律。发现所有行的重复周期都是 2 * nRows - 2对于首行和末行之间的行,还会额外重复一次,重复的这一次距离本周期起始字符的距离是 2 * nRows - 2 - 2 * iclass Solution {public: string convert(string s, int nRows) { // Start

2013-10-09 15:01:22 5678 2

原创 [LeetCode]Longest Palindromic Substring

Longest Palindromic Substring此题用Manacher算法解答,时间O(n),空间O(n).首先在字符串的首尾,以及每个字符之间加上'#',形成新字符串s1,这样可以统一处理子串为奇数或偶数的情况。我们用一个数组p来保存s1字符串中以每个字符为中心时,左右对称扩展的最大值,即以该字符为中心时的最大对称长度。例如:#a#b#b#a#,最中间的'#'的p值为4。接着我们扫描所

2013-10-09 14:09:54 1259

原创 [LeetCode]Add Two Numbers

/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */class Solution {public: ListNode *ad

2013-10-09 00:06:50 1090

原创 [LeetCode]Longest Substring Without Repeating Characters

此题用一个hash table保存每个字符上一次出现过的位置。从前往后扫描,假如发现字符上次出现过,就把当前子串的起始位置start移动到上次出现过的位置之后。同时,由于start移动,当前子串的内容改变,start移动过程中经历的字符都要剔除。class Solution {public: int lengthOfLongestSubstring(string s) {

2013-10-08 14:51:33 2840 1

原创 [LeetCode]Median of Two Sorted Arrays

Median of Two Sorted Arrays这题挺难的,边界条件老是考虑不清楚。所以在这里记录一下思路,免得将来忘记。There are two sorted arrays A and B of size m and n respectively. Find the median of the two sorted arrays. The overall run time

2013-10-08 14:17:59 1185 1

原创 [LeetCode]Two Sum

Two Sum这题思路很简单,创建一个hash table,用来存放访问过的数值和对应的位置。从头到尾循环,假如hash table里面有匹配的数值,则取出对应的数值的位置并直接返回。Given an array of integers, find two numbers such that they add up to a specific target number.The f

2013-10-08 13:36:06 1589

自己编写的80386虚拟机NXVM

一个完整的小型虚拟机,模拟了IBM PC/AT的诸多设备:80386 CPU,内存,中断控制器,实时时钟,软驱,硬盘,DMA,键盘和显示器…… 能在Linux终端窗口、Win32窗口(此时还模拟了点阵字体)、Win32控制台这3种条件下运行,很好玩。 由于保护模式还不完整,所以暂时只能跑MS-DOS 6.22。 此处仅提供源码下载,若需要DOS镜像、开发设计文档和其他资料请移步我的BLOG。

2013-10-18

LZW文件压缩器源代码

实现了一个基于LZW算法的文件压缩程序,能够压缩/解压缩 不限大小的文件;使用Hash表。

2012-04-10

makefile生成工具

该程序自动分析C代码文件的引用关系并自动生成makefile供linux下编译连接使用。

2012-04-10

C头文件引用关系分析程序

win/linux通用C代码,编译后在命令行中以C源代码作为参数,分析这些C代码的头文件引用关系

2012-04-10

BMP图像读写、格式转换、处理函数

提供了一系列编写好的函数,可直接对2色位图、16色位图、256色位图、24位真彩色、32位增强真彩色位图进行读取、写入、格式互相转换、反色等操作。windows和linux下通用,仅调用标准C函数,保证兼容性。包含一个范例代码供使用参考。

2012-04-10

人工生命Tierra模拟器源码和文档

Tierra 6.02完整源代码和文档; 附带中文幻灯片详解文档

2012-04-02

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除