- 博客(23)
- 资源 (4)
- 收藏
- 关注
原创 二叉树前序中序或中序后序建树
问题:已知前序中序遍历构建二叉树 因为前序遍历中的根为第一个在中序遍历中找到根的下标讲中序遍历分成两部分,左边为左子树,右边为右子树。前序遍历中第二个为左子树的根,以此类推递归求解。 后续遍历根在最后,倒数第二个为右子树的根,同理可求。 #include #include #define N 7 typedef struct Node Tree
2013-12-08 22:37:15
894
原创 线性时间排序
#include //A为排序前的数组,n为A长度,B为排序后数组,k为【0,k】之间的数排序 void counting_sort(int A[], int n, int B[], int k); void print(int B[], int n); //基数排序d为位数 void radix_sort(int A[], int n, int d); //返回num中第n位的数(从右往左) i
2013-12-07 23:05:52
435
原创 快速排序
#include void swap(int *a, int *b); int partition(int A[], int p, int r); void quicksort(int A[], int p, int r); void print(int A[], int n); int main(int argc, char *argv[]) { int a[]={2,8,7,1,3,5,
2013-12-07 23:03:11
481
原创 堆排序
#include #include #define PARENT(i) ((i)/2) #define LEFT(i) (2*(i)) #define RIGHT(i) (2*(i)+1) typedef struct{ int a[1000]; int size; }Heap; Heap* initial_heap(int a[], int n); void print_heap(He
2013-12-07 22:57:53
507
原创 逆序对
#include //直接枚举 int inverse_pair1(int *a, int n) { int count=0; int i,j; for(i=0;i<n;++i) for(j=i+1;j<n;++j) if(a[i]>a[j]) count++; return count; } //用归并排序的思想 int merge(int *a, int
2013-12-07 22:51:18
475
原创 递归目录统计文件个数与行数
# -*- coding: cp936 -*- import os def ftw(curdir): '''递归目录''' global count_file global count_line dirname=os.listdir(curdir) for name in dirname: name=os.path.join(curdir,
2013-10-07 15:54:50
814
原创 python学习笔记
1. __init__ 构造函数 strlist=s.split()以空格为分界将字符串s分割成list 2.os 模块 os.listdir(dirname):列出dirname下的目录和文件 os.getcwd():获得当前工作目录 os.curdir:返回当前目录('.') os.chdir(dirname):改变工作目录到dirname os.path.isdir(
2013-10-07 15:51:22
536
原创 emacs配置
;;emacs左边显示行号 (global-linum-mode t) ;;emacs模板插入 (auto-insert-mode) (setq auto-insert-query nil) ;;(add-hook 'find-file-hooks 'auto-insert) (setq auto-insert-directory "~/.emacs.d/inser
2013-06-09 19:17:51
542
转载 tcpdum
如何使用tcpdump来分析收发的TCP数据 我用的命令: sudo tcpdump -i eth1 src portrange 10580-10581 # 看本机eth1上有没有收到对方10580-10581端口发过来的数据 sudo tcpdump -i eth1 dst portrange 10580-10581 # 看本机通过eth1向任何主机的10580-10581上有没
2013-06-09 19:12:36
664
原创 freebsd ppp连接
在/etc/ppp/ppp.conf最后加上 adsl: set device PPPoE:网卡名 set authname xxx set authkey xxx set dial set login add default HISADDR /etc/rc.d/ppp start启动
2013-02-11 18:33:33
437
原创 安装freebsd
制作u盘安装系统 dd if=Freebsd××.img of=/dev/da0s1 bs=10240 conv=sync 下个装软件的iso放在其他分区 挂载其他分区 mount_ntfs /dev/ad0s1 /mnt 挂载显示中文加-C UTF-8 mount_cd9660 /dev/`mdconfig -f cdimage.iso` /mnt 用sysinstall通过
2013-02-09 15:18:09
364
原创 freebsd挂载
挂载光驱 mount -t cd9660 /dev/acd0 /mnt 挂载U盘 mount -t msdos /dev/da0s1 /mnt 中文 mount -t msdos -L zh_CN.UTF-8 /dev/da0s1 /mnt 挂载ISO镜像文件 mount -t cd9660 /dev/`mdconfig -f cdimage.iso`
2013-02-08 17:36:51
537
原创 freebsd 添加用户(组)
添加用户 adduser 用户名 添加组 pw groupadd 组名 将用户添加到组 pw groupmod 组名 -m 用户名 查看组信息 pw groupshow 组名
2013-01-01 18:19:29
2167
原创 emacs 自己常用命令
M-q 自动换行 C-v 向前移动一屏 M-v 向后移动一屏 C-@ mark M-w copy C-y paste M-f 向右移动一个词【对中文是移动到下一个标点符号】 M-b 向左移动一个词【对中文是移动到上一个标点符号】 C-a 移动到行首 C-e 移动到行尾 C-u num command C-k
2012-12-21 19:16:58
330
原创 list 简单函数应用
题目来自p93-94(移小球) #include #include #include using namespace std; int main() { list s; int n,t; cin>>n>>t; for(int i=1;i s.push_back(i); //在list尾加入元素的函数. for(int i=0;
2012-12-04 12:27:23
295
原创 freebsd自己常用命令
****ports**** 下载安装ports:#portsnap fetch extract 更新:#portsnap fetch update 默认配置安装软件:#make BATCH=YES install clean ****wget**** 下网站:#wget -r -p -np -k http://.... ****挂载**** 挂载中文U盘:#mount_msd
2012-11-05 22:03:22
521
转载 freebsd配置xmms中文
把perference->fonts 下面的play list 和main window都写成下面的 -sony-*-*-*-*-*-16-*-*-*-*-*-iso8859-1,-*-*-*-*-*-*-16-*-*-*-*-*-gbk-0
2012-11-05 22:01:44
457
转载 卡特兰数
令h(0)=1,h(1)=1,catalan数满足递推式[1]: h(n)= h(0)*h(n-1)+h(1)*h(n-2) + ... + h(n-1)h(0) (n>=2) 例如:h(2)=h(0)*h(1)+h(1)*h(0)=1*1+1*1=2 h(3)=h(0)*h(2)+h(1)*h(1)+h(2)*h(0)=1*2+1*1+2*1=5 另类递推式[2]:
2012-11-05 22:00:36
333
原创 矩阵快速幂
用矩阵m=[1,1;1,0]的n-2次幂乘A=[1,1],可以求得斐波那契数f(n),不过到100就19位数了(3736710778780434371)。 用来求递推取模是个好方法。 下面是c++的代码求f(n)。留着以后遇到类似的直接用,改改就能秒hdu1005,hdu1575,poj3070了。 #include using namespace std; clas
2012-11-05 21:51:07
368
原创 freebsd无线
乱弄一个下午加晚上把无线弄出来了,莫名奇妙的! 1.在#/etc/rc.conf加入 wlans_ipw0="wlan0" ifconfig_wlan0="WPA DHCP" 2.修改/etc/wpa_supplicant.conf network={ ssid="xxx" psk="xxx" } ssid为收到的无线名pks为密码 3./bo
2012-11-05 21:45:22
455
原创 freebsd安装flash插件
第1步 打开linux 兼容和linprocfs 在/etc/rc.conf加入linux_enable="YES" ,如果则加入 在/etc/sysctl.conf 中加入 compat.linux.osrelease=2.6.16 //不知道这个干什么的。因为是flaash11把手册上的挂载 linproc 去了。 然后运行以下命令: /etc/rc.d/abi start
2012-11-05 21:44:19
1049
原创 freebsd安装fcitx
先在ports里安装fcitx #whereis fcitx /usr/ports/chinese/fcitx cd /usr/ports/chinese/fcitx make install clean 再配置 # cat ~/.xinitrc export LC_ALL=zh_CN.UTF-8 export LANG=zh_CN.UTF-8 export LC_C
2012-11-05 21:42:19
1004
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅