随笔分类 -  算法

摘要:in_cksum(addr, len)u_short *addr;int len;{ register int nleft = len; register u_short *w = addr; register u_short answer; register int sum = 0; /* * Our algorithm is simple, using a 32 bit accumulator (sum), * we add sequential 16 bit words to it,... 阅读全文
posted @ 2012-01-05 15:23 lxgeek 阅读(642) 评论(0) 推荐(0)
摘要:实现《机器学习》19页的FIND-S算法。验证不同的实例顺序开始于非最特殊假设。#__author__=lx#__date__=2011.10.18#__brief__=FIND-S, from 'machine learning' 19def find_s(): x1 = [ 'sunny', 'warm', 'nurmal', 'strong', 'warm', 'same' , 1 ] x2 = [ 'sunny', 'warm', 'h 阅读全文
posted @ 2011-10-18 16:09 lxgeek 阅读(3398) 评论(0) 推荐(0)
摘要:/* * author: lx * date: 2011-09-16 * brief: programming pearls column2 */#include <stdio.h>#include <stdlib.h>voidmove_vector( char* b, int m, int n ){ int i = 0; int j; char temp; for ( ; i < n ; i++ ) { for ( j = i; j < m; j += n ) {... 阅读全文
posted @ 2011-09-17 13:23 lxgeek 阅读(181) 评论(0) 推荐(0)
摘要:/*ID: lxlenovos1PROG: beadsLANG: C++*/#include <iostream>#include <fstream>#include <string>#include <vector>#include <string.h>#include <stdlib.h>#include <stdio.h>using namespace std;typedef struct ring{ char a; struct ring *flink; struct ring *slink;} rin 阅读全文
posted @ 2011-08-10 21:53 lxgeek 阅读(291) 评论(0) 推荐(0)
摘要:In many situations when designing statistical software, the number of variables a dis-crete distribution will have is not known in advance (at compilation time). There existsa need to generate discrete multidimensional distributions on the fly.Multi-way arraysOne obvious way to store these multidime 阅读全文
posted @ 2011-05-12 09:40 lxgeek 阅读(348) 评论(0) 推荐(0)
摘要:Is Friday the 13th really an unusual event?That is, does the 13th of the month land on a Friday less often than on any other day of the week? To answer this question, write a program that will compute the frequency that the 13th of each month lands on Sunday, Monday, Tuesday, Wednesday, Thursday, Fr 阅读全文
posted @ 2011-05-03 17:23 lxgeek 阅读(632) 评论(0) 推荐(0)
摘要:A group of NP (2 ≤ NP ≤ 10) uniquely named friends has decided to exchange gifts of money. Each of these friends might or might not give some money to any or all of the other friends. Likewise, each friend might or might not receive money from any or all of the other friends. Your goal in this probl 阅读全文
posted @ 2011-05-01 22:45 lxgeek 阅读(705) 评论(0) 推荐(0)
摘要:比如这样:/* the struct of the node by adjacency-list representation */typedef struct{ /* the name of node */ string nodename; /* the list of each node */ vector< string > nodelist; /* the begin probability of the node */ vector< float > nodeprob;} nbnode; 阅读全文
posted @ 2011-03-16 15:03 lxgeek 阅读(2934) 评论(2) 推荐(0)

点击右上角即可分享
微信分享提示