会员
众包
新闻
博问
闪存
赞助商
HarmonyOS
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
sxcww
博客园
首页
新随笔
联系
管理
订阅
上一页
1
2
3
4
5
下一页
2014年5月28日
冗余构造
摘要: #include#include #includeusing namespace std;class SuperString{private: char *str;public: SuperString(const char *s=0):str(0){ if(s!=0){ str=new char[strlen(s)+1]; ...
阅读全文
posted @ 2014-05-28 20:55 sxcww
阅读(203)
评论(0)
推荐(0)
2014年5月20日
编程之美-数组中最长递增子序列(包括输出)
摘要: #include #define N 8using namespace std;int main(){ int a[N]={1,-1,2,-3,4,-5,6,-7}; int lis[N]; int result[N];//结果 for(int i=0;i a[j] && lis[i] =0;t--){ if (b > m) ...
阅读全文
posted @ 2014-05-20 21:23 sxcww
阅读(738)
评论(0)
推荐(0)
二分K-均值算法
摘要: 伪代码: 将所有点看成一个簇当簇数目小于k时对于每一个簇 计算总误差 在给定的簇上面进行k-均值聚类(k=2) 计算将该簇一分为二之后的总误差选择使得误差最小的那个簇进行划分操作 def biKmeans(dataSet,k): m=np.shape(dataSet)[0] clusterAssment=np.mat(np.ze...
阅读全文
posted @ 2014-05-20 16:21 sxcww
阅读(708)
评论(0)
推荐(0)
2014年5月19日
k均值算法
摘要: import matplotlib.pyplot as pltimport numpy as npimport timefrom django.template.defaultfilters import centerdef loadDataSet(fileName): dataMat=[] ...
阅读全文
posted @ 2014-05-19 15:54 sxcww
阅读(784)
评论(0)
推荐(0)
split和strip
摘要: str.strip([chars]) 删除字符串左右两端的相应字符,直到没有符合的字符为止。(lstrip则是只删除左侧的字符,rstrip则是只删除右侧的字符。) In [4]: t='wwerefdfww'In [5]: t.strip('w')Out[5]: 'erefdf'str.split([sep[, maxsplit]]) 根据规定的字符将字符串进行分割 In [1]:...
阅读全文
posted @ 2014-05-19 14:19 sxcww
阅读(196)
评论(0)
推荐(0)
2014年5月18日
编程珠玑-向量旋转
摘要: #include using namespace std;//将前i个元素复制到临时数组中templatevoid func0(T a[],int len,int i){ char *temp=new T[i]; int j; for(j=0;jvoid my_swap(T& a,T& b){ T temp; temp=a; a=b; b=temp;...
阅读全文
posted @ 2014-05-18 21:50 sxcww
阅读(202)
评论(0)
推荐(0)
2014年5月15日
dir函数
摘要: dir函数返回任意对象的属性和方法列表,包括模块对象、函数对象、字符串对象、列表对象、字典对象。。。等1,class test: def func(self): pass def __dir__(self): return ['a','b','c']a=tes...
阅读全文
posted @ 2014-05-15 22:04 sxcww
阅读(571)
评论(0)
推荐(0)
cookies和sessions
摘要: response 为HttpResponse对象,request为HttpRequest对象 Cookies 设置Cookies response.set_cookie("cookie_key","value") 获取Cookies value = request.COOKIES["cookie_key"] 删除Cookies response.del...
阅读全文
posted @ 2014-05-15 15:43 sxcww
阅读(274)
评论(0)
推荐(0)
2014年5月13日
operator->
摘要: 在学习Stl的过程中,经常看到->符号的重载,但一直不太明白。 今天做了一个小测试,来看看如果调用它。 以list的迭代器为例,在 pointer operator->() const { return &(operator*());}中加入 cout str_list; str_list.push_back(str); list::iterator it=str_list...
阅读全文
posted @ 2014-05-13 21:19 sxcww
阅读(199)
评论(0)
推荐(0)
2014年5月5日
operator++() 和operator++(int)
摘要: #include using namespace std;class A{public: int a;public: A& operator++(){ cout<<"A& operator++()"<<endl; a=a+1; return *this; } A operator++(int){ cout<<"A...
阅读全文
posted @ 2014-05-05 19:21 sxcww
阅读(1062)
评论(0)
推荐(0)
上一页
1
2
3
4
5
下一页
公告