自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

  • 博客(22)
  • 资源 (1)
  • 收藏
  • 关注

原创 python map/filter/reduce(转)

python有几个内置的函数很有意思:map/filter/reduce,都是对一个集合进行处理,filter很容易理解用于过滤,map用于映射,reduce用于归并,这几个词还是太抽象了,下面的代码精确的说明了这几个函数的用途:[quote]map[/quote][code="python"]def map_imp(function, sequence) : if fu...

2011-07-28 21:59:28 108

原创 Python多线程实例

[code="python"]from threading import Threadclass Task(Thread): def __init__(self, count): super(Task, self).__init__() #Thread.__init__(self) self.count = count ...

2011-07-26 22:00:59 124

原创 python转码

首先用utf8编码形式写一个测试用的txt文件[code="python"]>>> file = open('test.txt','r')>>> txt = file.read()>>> txt'\xe8\xbf\x99\xe6\x98\xaf\xe4\xb8\x80\xe4\xb8\xaa\xe6\xb5\x8b\xe8\xaf\x95\xe6\x96\x87\xe4\xbb...

2011-07-23 17:21:05 273

原创 对适配器模式的理解

适配器模式分两种:对象适配器,类适配器。先上类图:[img]http://dl.iteye.com/upload/attachment/508760/148541b8-c7d9-3991-a4a6-66bfa177eb61.bmp[/img]区别如下:[size=large][b]1,类适配器:[/b][/size]若client所调用的target是一个接口,则adapter...

2011-07-02 00:02:07 131

原创 投硬币概率模拟程序

[code="c"]#include #include //头像面朝上的概率 int heads(){ return rand() < RAND_MAX/2;}int main(int argc, char *argv[]){ int i, j, cnt; //N为每次实验投币的次数,M为实验的次数 int N = atoi(argv[1...

2011-07-01 14:31:50 1034

原创 筛减法求素数

这种方法的求素数的效率很高[code="c"]#include #include /*筛选法求素数,即质数 素数是只能被1和自身整除的数 从2开始递增,删除此数的倍数,则以后出现的就都是素数了 */int main(int argc, char *argv[]){ //atoi函数将字符串转化为长整型 int i, j, N = atoi(a...

2011-07-01 14:22:42 160

原创 C语言可变参数函数示例

[code="c"]#include #include int demo(char *msg, ...){ va_list argp; int num = 0; char *para; va_start(argp, msg); while(1) { para = va_arg(argp, char *); if (strcmp(para, "...

2011-06-30 10:39:02 89

一个C语言指针问题

今天重新拿起C语言的书学习学习,遇到了一个诡异的问题,开始不可理解,现在记录下整个分析过程。首先上代码:[code="c"]#include void strcopy(char *s, char *t){ while ((*s++ = *t++) != '\0') ;}int main(){ int i = 3; char...

2011-06-26 16:31:50 301

java截图小程序

一时心血来潮,参考网上所搜到的代码,写了个截图程序,基本实现功能,可以算作第一版,代码见附件

2011-06-01 09:32:40 108

对java线程join方法的理解

先上代码:[code="java"]public class ThreadA extends Thread { @Override public void run() { System.out.println("A start..."); for (int i = 0; i < 10; i++) { try { Thread.sleep(1000);...

2011-05-26 09:31:42 65

原创 简单工厂模式-工厂方法模式-抽象工厂模式

[b]简单工厂模式又称静态工厂模式[/b]下面看代码示例:[code="java"]public interface Robot { public void work();}[/code][code="java"]public class Factory { public static Robot create(Class clazz) { try { Rob...

2011-05-24 09:36:45 92

原创 关于单例模式的整理

[b]写法一:[/b][code="java"]public class Singleton { /** * 线程安全,因为jvm在加载类时,对static的属性只能有一个线程执行一次 * 比较复杂的创建过程可以放在static{}里面 */ private static Singleton instance = new Singleton(); priva...

2011-05-23 21:13:38 71

原创 模板方法模式与回调函数

先上模板方法模式的类图:[img]http://dl.iteye.com/upload/attachment/486461/4f20bd54-0a8b-373c-bb41-d86e643ee67b.png[/img]代码演示:[code="java"]public abstract class AbstractClass { public abstr...

2011-05-23 20:05:54 217

一个字符串处理实例

这个示例实现的功能:将文本中类似于‘21-12-2011’这样的日期类型找出来,替换为‘2011-12-21’上代码:[code="python"]import repat = '\d{1,2}-\d{1,2}-\d{4}'p = re.compile(pat)f = open('c:/oreacle++emp.txt')t = f.readline()while ...

2011-05-22 08:05:08 176

原创 关于mysql乱码问题的解决方案

1.连接串设置编码:jdbc:mysql://127.0.0.1:3306/ibitispring?characterEncoding=UTF-8 2.在建表的时候设置编码: 创建表[code="sql"]CREATE TABLE `type` ( `id` int(10) unsigned NOT NULL auto_increment, `flag_delet...

2011-05-21 10:03:08 85

原创 Project Euler每帖一题(005)

题目:[quote]2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.What is the smallest positive number that is evenly divisible by all of the nu...

2011-05-11 10:34:32 114

原创 Project Euler每帖一题(006)

题目:[quote]The sum of the squares of the first ten natural numbers is,12 + 22 + ... + 102 = 385The square of the sum of the first ten natural numbers is,(1 + 2 + ... + 10)2 = 552 = 3025...

2011-05-11 08:49:01 157

原创 Project Euler每帖一题(002)

题目:[quote]Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be:1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ......

2011-05-10 21:37:27 103

原创 Project Euler每帖一题(001)

[quote]题目:If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.Find the sum of all the multiples of 3 or 5 below 1000.[/...

2011-05-10 20:44:31 98

用pil模拟一下小时候的一个玩具

以前玩过个玩具,类似于齿轮,一个小齿轮在一个大齿轮里面转,把笔插入那个小齿轮的小孔,然后一圈一圈转,就有了一个神奇的图案。用python写了下,也不知对不对,图是出来了,分析了一下规律,应该就是一个公转自转问题。下面上代码:[code="python"]#! /usr/bin/env python#coding=utf-8import Image,ImageDraw,sys,mat...

2011-04-23 14:27:56 121

原创 软通面试总结

今晚去软通动力面试,受挫了。总结一下:1.不要太老实,尤其和人事交谈的时候,第一印象很重要2.话不能多,不要太活跃,尽量低调,老实,不要显得太自信,太自负3.摸清行情,工资要开的正好适合4.要在基础知识上做充分准备,平时要每天学习,积累,关于面试官问的问题,要尽量了解清楚意思技术面试问的问题:1.clone的实现2.深拷贝和浅拷贝3.线程锁4.自定义标签的实...

2011-04-06 21:16:47 2706 4

原创 使用 Spring 更好地处理 Struts 动作(转)

Struts Recipes 的合著者 George Franciscus 将介绍另一个重大的 Struts 整合窍门 —— 这次是将 Struts 应用程序导入 Spring 框架。请跟随 George,他将向您展示如何改变 Struts 动作,使得管理 Struts 动作就像管理 Spring beans 那样。结果是一个增强的 web 框架,这个框架可以方便地利用 Spring AOP 的优...

2010-09-11 09:24:45 79

teach you mysql in10 minutes

一本学习mysql很好的书,简洁明了,包含了数据库开发的一些基本操作

2010-01-16

空空如也

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

TA关注的人

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