字典树(Trie树)的C语言实现

字典树也称Trie树,是一种哈希树,适用于字符串的查找,存储,统计,排序等操作。

Trie树的C语言实现代码如下:


#define MAX 26    //26个字母
#define SLEN 100   //节点中存储的字符串长度
//Trie结构体定义
struct Trie
{
    struct Trie *next[MAX];
    char s[SLEN];      //节点处存储的字符串
    int isword;         //节点处是否为单词
    char val;           //节点的代表字符
} *root;
//初始化Trie树
struct Trie *init()
{
    struct Trie *root ...

继续阅读

Java获取屏幕截图示例

Java实现屏幕截图获取需要使用java.awt包下的工具类

一个最简单的获取屏幕截图的代码实现如下所示:


import java.awt.AWTException;
import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;

public class ScreenshotGetter {
	public BufferedImage getScreenshot() throws AWTException {
		final Robot robot = new ...

继续阅读

Python LEGB作用域规则简述

What exactly are the Python scoping rules?

Python的作用域规则到底指的是什么?

If I have some code:

如果我有一段代码:


code1
class Foo:
   code2
   def spam.....
      code3
      for code4..:
       code5
       x()

Where is x found? Some possible choices include the list above:

x在哪里能找到?可能的选择列举如下:

  1. In the ...

继续阅读

Python程序员常犯的10个错误

原文链接:http://www.toptal.com/python/top-10-mistakes-that-python-programmers-make

BY MARTIN CHIKILIAN - SENIOR SOFTWARE ENGINEER @ TOPTAL

About Python 关于Python

Python is an interpreted, object-oriented, high-level programming language with dynamic semantics. Its high-level built in data structures, combined with dynamic typing ...

继续阅读

CDN bootstrap glyphicons图标IE下无法显示

百度,新浪等站点提供了CDN JavaScript公用库,包含了前端开发常用的JavaScript库文件与CSS样式表,开发者可以很方便地从这些CDN引用所需的样式文件,还可以保证不错的响应速度。

bootcss中文站、百度的bootstrap库引用方式如下所示:

<link rel="stylesheet" href="http://cdn.bootcss.com/twitter-bootstrap/3.0.3/css/bootstrap.min.css">
<script src="http://cdn.bootcss.com/twitter-bootstrap/3.0.3/js/bootstrap.min.js" type ...

继续阅读

年度归档