2016年7月28日

背包问题

摘要: #============================================================================== # def mybag(n,c,z,v): # w = [[0 for i in range(c+1)] for j in range(n+1)] # for i in range(n-1,-1,-1): # ... 阅读全文

posted @ 2016-07-28 16:10 Kermit.Li 阅读(144) 评论(0) 推荐(0)

2016年6月27日

正则表达式-邮箱的判断

摘要: import re def emaills(e): if (len(e) >= 5): if re.match("[a-zA-Z0-9]+\@[a-zA-Z0-9]+\.+[a-zA-Z]",e): return 'correct' return 'error' e = raw_input('please emaill:') print... 阅读全文

posted @ 2016-06-27 11:24 Kermit.Li 阅读(200) 评论(0) 推荐(0)

2016年6月23日

简单爬虫-初次尝试

摘要: import urllib import re def getHtml(url): page = urllib.urlopen(url) html = page.read() return html def getImg(html): reg = r'src="(.+?\.jpg)" pic_ext' imgre = re.compile(reg) ... 阅读全文

posted @ 2016-06-23 11:18 Kermit.Li 阅读(112) 评论(0) 推荐(0)

2016年6月20日

简单的堆排序-python

摘要: AA = raw_input().strip().split(' ') A = [] ###############初始化大堆############### def fixUp(A): k = len(A) - 1 while k >= 0 and A[k // 2] < A[k]: A[k // 2], A[k] = A[k],A[k // 2] ... 阅读全文

posted @ 2016-06-20 15:38 Kermit.Li 阅读(136) 评论(0) 推荐(0)

2016年6月12日

python归并排序

摘要: 由于某人问我要个归并排序,就凑合写了一个,AA = raw_input().split(' ') A = []; for num in AA: A.append(int(num)) def MergeSort(A): if len(A) <= 1: return A else: mid = int(len(A)/2) le... 阅读全文

posted @ 2016-06-12 21:24 Kermit.Li 阅读(139) 评论(0) 推荐(0)

2016年6月7日

python按位操作以及进制转换

摘要: a = raw_input() b = raw_input() c1 = int(str(a), 2)#2进制转化为10进制 c2 = int(str(b), 2) c = c1 ^ c2#按位异或 c = bin(int(str(c), 10))#10进制转换2进制 c =str(c) c = c[2:] rr = []; if len(str(a)) != len(c): ... 阅读全文

posted @ 2016-06-07 08:54 Kermit.Li 阅读(371) 评论(0) 推荐(0)

初学者迭代python

摘要: #汉诺塔 def hanni(n,A,B,C): if n == 1: print (A,'-->',C) else: # 将n-1个盘子移动到B上 hanni(n-1,A,C,B) # 将第n个移动到C上 print(A,'-->',C) # 将n-1个移动到C上 ... 阅读全文

posted @ 2016-06-07 08:52 Kermit.Li 阅读(150) 评论(0) 推荐(0)

2016年4月13日

大数相乘

摘要: clc; clear all; close all; A ='962898798798798978987898'; B = '9387978987987879899999999999999999999999999999999999999999999999999999999999999999'; A = fliplr(A); B = fliplr(B); result=zeros(1,lengt... 阅读全文

posted @ 2016-04-13 11:41 Kermit.Li 阅读(258) 评论(0) 推荐(0)

2016年4月11日

基本蚁群算法

摘要: //===================================================================== //基本蚁群算法源代码 //使用的城市数据是eil51.tsp //===================================================================== // AO.cpp : 定义控制台应用程序的入... 阅读全文

posted @ 2016-04-11 23:49 Kermit.Li 阅读(290) 评论(0) 推荐(0)

2015年7月18日

MATLAB绘图,绘双坐标轴,绘一图二轴等

摘要: clc;clear all;close all;% %% 画极坐标系% x = 0:.01 * pi:0.5 * pi;% y = cos(x) + sqrt(-1) * sin(x);% plot(y*2,'r','linewidth',5);% hold on% warning('off')% ... 阅读全文

posted @ 2015-07-18 21:52 Kermit.Li 阅读(3178) 评论(0) 推荐(0)

导航