摘要: #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 阅读(196) 评论(0) 推荐(0) 编辑
摘要: #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 阅读(724) 评论(0) 推荐(0) 编辑
摘要: 伪代码: 将所有点看成一个簇当簇数目小于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 阅读(697) 评论(0) 推荐(0) 编辑
摘要: import matplotlib.pyplot as pltimport numpy as npimport timefrom django.template.defaultfilters import centerdef loadDataSet(fileName): dataMat=[] ... 阅读全文
posted @ 2014-05-19 15:54 sxcww 阅读(773) 评论(0) 推荐(0) 编辑
摘要: 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 阅读(174) 评论(0) 推荐(0) 编辑
摘要: #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 阅读(192) 评论(0) 推荐(0) 编辑
摘要: dir函数返回任意对象的属性和方法列表,包括模块对象、函数对象、字符串对象、列表对象、字典对象。。。等1,class test: def func(self): pass def __dir__(self): return ['a','b','c']a=tes... 阅读全文
posted @ 2014-05-15 22:04 sxcww 阅读(542) 评论(0) 推荐(0) 编辑
摘要: 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 阅读(271) 评论(0) 推荐(0) 编辑
摘要: 在学习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 阅读(188) 评论(0) 推荐(0) 编辑
摘要: #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 阅读(1032) 评论(0) 推荐(0) 编辑