摘要: 1. 1 #include 2 3 #define SPACE ' ' 4 #define NEWLINE '\n' 5 6 int main() 7 { 8 int spaces,newlines,others; 9 char ch;10 spaces = newli... 阅读全文
posted @ 2014-07-11 01:00 践道者 阅读(375) 评论(0) 推荐(0) 编辑
摘要: 16. 1 #include 2 3 int main() 4 { 5 double remain = 100.0; 6 int years=0; 7 while(remain>0) 8 { 9 remain = remain * 0.08 + r... 阅读全文
posted @ 2014-07-06 12:48 践道者 阅读(368) 评论(0) 推荐(0) 编辑
摘要: 1. 1 #include 2 #define MINU 60 3 4 int main() 5 { 6 int minute, hour, m; 7 printf("请输入分钟:"); 8 while(scanf("%d", &m)) //如果输入的不是数字,则会退出 ... 阅读全文
posted @ 2014-07-06 00:37 践道者 阅读(483) 评论(0) 推荐(0) 编辑
摘要: 5. 1 #include 2 3 int main() 4 { 5 float you_sec; 6 printf("请输入你的年龄:"); 7 scanf("%f", &you_sec); 8 printf("年龄合计:%e 秒!\n", you_sec * ... 阅读全文
posted @ 2014-07-05 01:27 践道者 阅读(172) 评论(0) 推荐(0) 编辑
摘要: 6. 1 #include 2 3 void echo(); 4 5 int main() 6 { 7 /* 8 echo(); 9 echo();10 echo();11 printf("\n");12 echo();13 echo()... 阅读全文
posted @ 2014-07-04 00:42 践道者 阅读(201) 评论(0) 推荐(0) 编辑
摘要: 1. 1 #include 2 3 int main() 4 { 5 //将英寸转换为厘米 1英寸=2.54厘米 6 int inch; 7 printf("请输入英寸:"); 8 scanf("%d", &inch); 9 printf("%.2f 厘米... 阅读全文
posted @ 2014-07-03 23:42 践道者 阅读(258) 评论(0) 推荐(0) 编辑
摘要: 1 #include 2 #include "resource.h" 3 4 LRESULT CALLBACK MyWndProc( HWND hwnd, // handle to window 5 UINT uMsg, // message identifier 6... 阅读全文
posted @ 2014-07-03 00:13 践道者 阅读(406) 评论(0) 推荐(0) 编辑
摘要: 1 #include 2 #include "resource.h" 3 4 LRESULT CALLBACK MyWndProc( HWND hwnd, // handle to window 5 UINT uMsg, // message identifier 6... 阅读全文
posted @ 2014-07-02 01:23 践道者 阅读(1114) 评论(0) 推荐(0) 编辑
摘要: 1 #include 2 3 LRESULT CALLBACK MyWndProc( HWND hwnd, // handle to window 4 UINT uMsg, // message identifier 5 WPARAM wParam, // fi... 阅读全文
posted @ 2014-07-02 00:38 践道者 阅读(1239) 评论(0) 推荐(0) 编辑
摘要: http://mslog.sinaapp.com/archives/33今天在博客园看了一位哥的按需加载图片博客,将代码做成一个函数封装下,直接拿来主义用在我的站上,12345678910111213141516varfn=function(){ $("img").each(function(){//遍历所有图片 varothis=$(this),//当前图片对象 top=othis.offset().top-$(window).scrollTop();//计算图片top - 滚动条top if(top>$(window).height()){//如果该图片不可见 . 阅读全文
posted @ 2014-03-13 17:27 践道者 阅读(240) 评论(0) 推荐(0) 编辑
摘要: 1 #include "stdio.h" 2 3 #include "stdlib.h" 4 #include "io.h" 5 #include "math.h" 6 #include "time.h" 7 8 #define OK 1 9 #define ERROR 0 10 #define TRUE 1 11 #define FALSE 0 12 13 #define MAXSIZE 20 /* 存储空间初始分配量 */ 14 15 typedef int Status; /* Statu 阅读全文
posted @ 2014-01-08 22:10 践道者 阅读(409) 评论(0) 推荐(0) 编辑
摘要: stdout:标准输出stderr:标准错误print 相当于 sys.stdout.write() + 换行一个将数据流写入文件的程序,文件名为:main.pydef main(out=sys.stdout): config = 'Hello' out.write(config)if __name__ == '__main__': main()在命令行下运行main.py > abcdfg.txt就会将Hello字符串写进abcdfg.txt文件中具体看这里:http://hi.baidu.com/liuhelishuang/item/41f2bbf21 阅读全文
posted @ 2013-08-16 10:54 践道者 阅读(2471) 评论(0) 推荐(0) 编辑
摘要: class LoopError(Exception):passrs = ''try: for i in range(1, 3): print i rs = 'one ' if i == 1: for j in range(12, 22): print j if j == 13: rs = 'bbs' raise LoopErrorexcept LoopError: #跳出,遇到LoopErr... 阅读全文
posted @ 2013-07-25 16:23 践道者 阅读(2539) 评论(0) 推荐(0) 编辑
摘要: def t(b,c): print b print cd = {'b':32, 'c':321}t(*d)t(**d)t(*d) d的键将被分解传递到函数t中,打印的是键名b, ct(**d) d的值被分解成 b = 32 , c=321 传递给函数,打印的是32和321 阅读全文
posted @ 2013-07-25 09:40 践道者 阅读(326) 评论(0) 推荐(0) 编辑
摘要: 1 #coding=utf-8 2 3 from twisted.internet import reactor,protocol 4 5 class QuickClient(protocol.Protocol): 6 def connectionMade(self): 7 print dir(self.transport.getPeer()) 8 print "port:%s type:%s "%(self.transport.getPeer().port, self.transport.getPeer().type) 9 pri... 阅读全文
posted @ 2013-07-24 17:40 践道者 阅读(1555) 评论(0) 推荐(0) 编辑
摘要: input = raw_input('\033[36;1mShell command[q to quit]:\033[0m') 阅读全文
posted @ 2013-07-24 09:49 践道者 阅读(266) 评论(0) 推荐(0) 编辑
摘要: 用__new__与__init__不同,通过继承内建类型对象,__new__可以用来创建一个简单的新类型,在__new__加入一些动作以完成创建。class RoundFloat(float): def __new__(cls, val): return super(RoundFloat, cls).__new__(cls, round(val, 2))以上代码创建了一个保留2位小数的四舍五入的浮点数 阅读全文
posted @ 2013-07-22 14:52 践道者 阅读(240) 评论(0) 推荐(0) 编辑
摘要: 事實上Deferred的確就像是一連串的動作,用callback的形式被串在一起,我們用deferred或許可以這樣寫d.addCallback(洗菜)d.addCallback(切菜)d.addCallback(放到鍋中)d.addCallback(加鹽)如果只是這樣看起來就像是單純的責任鍊,做完一件事情把結果往下丟,但是,如果發生例外呢?def 切菜(data): raise 切到手指('Ouch!')如果只是單純的責任鍊,會從最初呼叫它的地方丟出來,如果只是一般的單thread程式這樣跑下來,其實加上一個try except就可以抓到了,但是twisted是處理非同步的事 阅读全文
posted @ 2013-07-19 17:08 践道者 阅读(493) 评论(0) 推荐(0) 编辑
摘要: l = map(chr, xrange(256)) #将ascii转为字符串_idmap = str('').join(l)del l# Construct a translation string_idmapL = None #定义一个全局变量def maketrans(fromstr, tostr): """maketrans(frm, to) -> string Return a translation table (a string of 256 bytes long) suitable for use in string.trans 阅读全文
posted @ 2013-07-18 15:49 践道者 阅读(587) 评论(0) 推荐(0) 编辑
摘要: def capwords(s, sep=None): """capwords(s [,sep]) -> string Split the argument into words using split, capitalize each word using capitalize, and join the capitalized words using join. If the optional second argument sep is absent or None, runs of whitespace characters are replaced 阅读全文
posted @ 2013-07-18 15:00 践道者 阅读(1589) 评论(0) 推荐(0) 编辑