归档 2014年5月

字典树(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 = (struct Trie *)malloc(sizeof(struct ...

继续阅读

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 Robot();
		Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize();
		int width = (int) dimension.getWidth();
		int ...

继续阅读

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 enclosing ...

继续阅读

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 and dynamic binding, make it ...

继续阅读

CDN bootstrap glyphicons图标IE下无法显示

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

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

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

然而,在使用百度和新浪CDN的bootstrap 3.0.3时,笔者发现在IE下部分glyphicons图标无法正常显示,而在chrome浏览器下可以显示。

例如https://bookshadow.com/weblog/2014/05/13/bootstrap-carousel-js/中的轮播组件,在chrome下可以看到carousel左右两侧的三角形glyphicons图标,如下图所示:

bootstrap-carousel-glyphicons-chrome

而在IE浏览器下却无法显示,效果见下图。

bootstrap-carousel-glyphicons-ie

查阅stackoverflow上的相关问答,发现此贴中也提到了相同的问题:http://stackoverflow.com/questions/19026479/only-some-glyphicons-showing-in-ie

用户olahell的回答比较妥当:

I have found the solution. It was quite simple. Unfortunately I won't be able ...

继续阅读

每日归档

上个月

下个月

归档