摘要: LeetCode interview Questions:Add binay1.int之类的数可以使用small2.直接在字符串使用二进制的加法http://www.leetcode.com/onlinejudge 需要FQclass Solution { public: int string_to_int(string str) { int result = 0; int level = 1; for(int i = str.length() - 1; i >=0 ; i--) { if (str[i] == '... 阅读全文
posted @ 2012-10-09 15:52 junfeng_feng 阅读(153) 评论(0) 推荐(0) 编辑
摘要: #include<iostream> using namespace std; int main() { uint32_t size; cin >> size; int arr[size]; printf("size address::%x\n", &size); printf("array address::%x\n", &arr[0]); return 0; }这段代码,可以编译通过。可以在栈上开辟一个运行时才知道大小的数组。(参考:http://ericwang.github.com/c_cpp/2010/0 阅读全文
posted @ 2012-08-27 19:27 junfeng_feng 阅读(640) 评论(0) 推荐(0) 编辑
摘要: from math import log def I(*args): total = sum(args) + 0.0 result = 0.0 for i in args: if i == 0: result += 0 else: result += i / total * log( i / total, 2) return -result #num表示分类的个数 def E(num, *args): if len(args) % num != 0: pr... 阅读全文
posted @ 2012-06-10 16:06 junfeng_feng 阅读(1139) 评论(0) 推荐(0) 编辑
摘要: #!C:/Python27/python.exe #coding=gbk import sys __author__ = "junfeng_feng" """Python实现Apri算法 input:数据文件名 最小支持度 ouput:所有频繁项集 支持度 Usage:python Apri.py filename min_surpport Exampe: python Apri.py data.txt 2 3点说明 1、使用Python不到70行的代码,简洁完整的实现Apri算法 2、使用内存存放数据(Python会做相应大文件的优化) 3、 阅读全文
posted @ 2012-06-05 20:13 junfeng_feng 阅读(540) 评论(0) 推荐(0) 编辑
摘要: #coding=gbk import os #operating system import sys #system import copy from pprint import pprint #perfect print from operator import attrgetter a = [1, 2, 3, 4, 5] b = [6, 7, 8, 9, 10] #python使用引用计数 c = a print c #[1, 2, 3, 4, 5] c[0] = -1 print c #[-1, 2, 3, 4, 5] print a #[-1, 2, 3, 4, 5] a[... 阅读全文
posted @ 2012-05-29 20:29 junfeng_feng 阅读(410) 评论(0) 推荐(0) 编辑
摘要: 服务器:/* *run command: * g++ server.cpp -o server && ./server */ #ifndef SERVER #define SERVER #include<arpa/inet.h> #include<assert.h> #include<stdio.h> #include<stdlib.h> #include<pthread.h> #include<errno.h> #include<assert.h> #include<string.h&g 阅读全文
posted @ 2012-05-29 20:04 junfeng_feng 阅读(561) 评论(0) 推荐(0) 编辑
摘要: -module(exam). -compile(export_all). %1杨辉三角 start(N) when is_integer(N) -> print(N,1,1). %C表示行数 %LC表示C对应的list print(N,1,_) -> io:format("~p~n",[[1]]), print(N,2,1); print(N,2,_) -> io:format("~p~n",[[1,1]]), print(N,3,[1,1]); %Lc_minus_1 表示C-1行的list print(N,... 阅读全文
posted @ 2012-05-29 20:01 junfeng_feng 阅读(395) 评论(0) 推荐(0) 编辑
摘要: //字符串同素:包含相同的char,以及char出现的次数#include <iostream> #include <stdio.h> #include <map> #include <assert.h> #include <string.h> #include "boost/smart_ptr.hpp" using namespace std;const int CHAR_NUMBER = 256;//答题的时候,好像写成255了 bool get(char* str,int* arr) { if( str == 阅读全文
posted @ 2012-05-29 16:54 junfeng_feng 阅读(167) 评论(0) 推荐(0) 编辑
摘要: 写下书单,感叹自己大学前三年的孤陋,惋惜没有好好利用时间看看技术书籍,只会看课本学习老师教过的内容。很是惭愧,在下面的书单之前我没有额外看过除课本以外的任何技术书籍。在此特别感谢zcj,是他让我看到了我和他的差距,看到了他书桌上的计算机经典的书籍,我一下无地自容。下面所列均为计算机经典,希望在大四这一年看下这些书为时不晚!1.《C++ 编程思想》作为我的第一本课外书籍,不得不说我选对了,这个被侯捷先生归类为“C++四库全书”,看过这本书之后,我才知道自己之前以为掌握C++是多么幼稚的观点,也就是我是只“井底之蛙”。2.《Java编程思想》虽然作为我第二本买来的经典书籍,可以直到研究生之前的暑假 阅读全文
posted @ 2011-12-29 20:32 junfeng_feng 阅读(318) 评论(0) 推荐(0) 编辑
摘要: /* * mergesort_unrecursive.cpp * * Created on: Dec 14, 2011 * Author: junfeng * //从分治策略的机制入手,容易消除归并排序算法中的递归,事实上, //算法Mergesort的递归过程只是将待排序列 集合一分为二,直到待排序列集合 //只剩下一个元素为止,然后不断合并两个排好序的数组段。按此机制,可以首先 //将数组a中相邻元素两两配对。用合并算法将它们排序,构成n/2组长度为2的排好 //序的子数组段,然后再将它们 排序成长度为4的排好序的子数组段,如此继续下去, //直... 阅读全文
posted @ 2011-12-14 23:11 junfeng_feng 阅读(453) 评论(0) 推荐(0) 编辑