- 博客(13)
- 收藏
- 关注
原创 归并排序求逆序数
经典分治法实现归并排序求逆序数,算法来自算法导论归并排序的思想是将整个数组从中点不断的从中间分成两部分,然后进行归并的动作。在归并过程中,如果左边小于右边,不会产生逆序数,当左边大于右边时,会产生一个逆序数#include <stdio.h> int left[250003], right[250003]; long long count; void merge...
2017-12-27 17:46:07 177
原创 链表解决约瑟夫问题
利用链表解决约瑟夫问题,其中删除使用换位删除法 #include #include typedef struct _Node { int data; struct _Node *next; }Node; typedef struct _list{ Node
2017-12-25 16:35:17 383
原创 链表所有重复元素的删除
实现链表所有重复元素的删除#include#includetypedef struct _Node{ int data; struct _Node *next;}Node;typedef struct _list{ Node *head;}List;void add(List *pList,int number){ Node *p=(Node*)malloc(siz
2017-12-24 15:26:02 178
原创 数组的归并
将两个数组按顺序合并为一个数组#include#includeusing namespace std;void merge(vector a,vector b,vector &c){ int i=0,j=0; while(i<a.size()&&j<b.size()) { if(a[i]<b[j]) { c.push_back(a[i]); i++; }
2017-12-23 16:50:17 405
原创 线性表的建立,删除,查找
#include #includeusing namespace std;#define InitSize 10000typedef struct { int *data; int length;}SeqList;void ListInsert(SeqList &L,int i,int e){ int j; for(j=L.length;j>=i;j--) { L.d
2017-12-22 23:30:37 359
原创 二分查找
二分查找实现#includeconst int N=100000;int binaryseach(int a[],int n,int aim){ int first=0,last=n-1; //first=0 last=9 int mid; while(first<last) { mid=(first+last)/2; //mid 4 mid=
2017-12-22 14:44:18 146
原创 链表的删除
给定一个元素,删除链表中所有这个元素#include #include typedef struct _Node { int data; struct _Node *next; }Node; typedef struct _list{ Node *head; }List; void add(List *pList,in
2017-12-20 16:32:45 305
原创 Python实现线性判别
Python实现线性判别,参考周志华机器学习第三章 import numpy as npimport matplotlib.pyplot as pltmat=np.loadtxt('gua.txt')X1=mat[0:8,1:3] #好瓜的数据X0=mat[8:,1:3] #坏瓜的数据mean1=np.mean(X1, axis=0) #计算每一列的
2017-12-19 23:57:32 1699
原创 链表的归并
#include #include typedef struct _Node { int data; struct _Node *next; }Node; typedef struct _list{ Node *head; }List; void add(List *pList,int number) {
2017-12-19 21:23:54 231
原创 链表的建立
分别采用头插法,尾插法,升序建立链表#include#includetypedef struct _Node{ int data; struct _Node *next;}Node;typedef struct _list{ Node *head;}List;void add(List *pList,int number){ Node *p=(Node*)mallo
2017-12-19 16:38:48 313
原创 Python实现浅层神经网络
import numpy as npimport matplotlib.pyplot as pltdef sigmoid(z): return 1 / (1 + np.exp(-z))def forward(X, w1, w2, b1, b2): z1 = np.dot(w1,X) + b1 # w1=h*n X=n*m z1=h*m A1
2017-12-14 22:32:33 794 1
原创 Python实现逻辑回归
import numpy as npimport mathimport matplotlib.pyplot as pltdef sigmoid(z): h=1.0/(1+np.exp(-z)) return hdef costfunction(X,beta,y,b): m, n = np.shape(X) h=sigmoid(np.dot(X,beta.
2017-12-11 22:45:21 257
原创 二维方格子Ising模型代码
#include #include #include #include #includeusing namespace std;ofstream out("data.dat");const int L = 50; //模拟尺寸 const int MCS = 20000; //总的模拟步数 const
2017-12-11 17:32:02 6922 2
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人