自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

小猪爱拱地

勤奋和毅力是通向成功的阶梯

  • 博客(17)
  • 资源 (1)
  • 收藏
  • 关注

原创 背包问题(Knapsack problem) 之二

接着上一篇的背包问题。上一篇的实现利用了递归的思想,但是实现没有使用函数递归。下面我们使用函数递归的方法来实现背包问题。代码如下:#include #define MAX_WEIGHT 20#define MAX_COUNT 10 struct item{ int weight; int value; int index;};struct item

2015-03-29 13:13:00 642

原创 背包问题(Knapsack problem)

这是一类经典的算法问题。问题可以描述为: 给定一组物品 x(1, n), 每个具有重量 w(1, n) 和价值 v(1, n), 如何从这组物品里选择一个子集合,使得这个子集合的元素在满足总重量 w 小于或等于给定的重量W的条件下,总价值 V 最大。通用的算法是使用递归来求解。V(i, w) = max(V(i -1, w), V(i -1, w- w(i))+v(i))其中, V

2015-03-27 08:03:43 2994

原创 UDP通讯中数据不能写入文件的问题

写了一个简单的UDP通讯程序,客户端读文件,把数据写到服务器端;服务端读取数据,写到另一个文件里面。服务器端代码是这样的://#include "unp.h"#include #include #include #include #include #include #include intmain(int argc, char **argv){ int so

2015-03-22 13:50:36 1319

原创 linux BC命令行计算器

1. 基本用法:$ bc <<< 5*420$ bc <<< 5+49$ bc <<< 5-41或者$ echo "5*4" | bc20$ echo "5+4" | bc9$ echo "5-4" | bc1也可以把算式写到文件里面,然后一次计算。$ cat calcFile 5+56+7$ bc < calcFile 1013也可以使用HER

2015-03-17 01:50:03 5096

原创 使用 gnuplot 画图

1) 安装:sudo aptitude install gnuplot-x112)画图:先执行gnuplot,进入交互模式:$ gnuplot G N U P L O T Version 4.6 patchlevel 4 last modified 2013-10-02 Build System: Linux i686 Copyright (C) 1986-1

2015-03-14 01:28:39 3734

原创 Linux Kenrel Network maillist and git

1) mailist:netdev@vger.kernel.orghttp://www.spinics.net/lists/netdev/2)git:for fixes to existing code already in the mainline tree:http://git.kernel.org/cgit/linux/kernel/git/davem/net.g

2015-03-10 22:13:25 1067

原创 内核模块参数

在代码中,可以这样写:static int cfg_value = 3;module_param(cfg_value, int, 0764);然后,加载内核的时候,可以添上制定的参数值(不加的话,就是代码的数值)。insmod module_name cfg_value=100内核模块加进来之后,可以在 /sys/module/{module_name}/parameters

2015-03-09 22:11:11 606

转载 30 Unforgettable Books Every Parent Should Read To Their Kids Before They Grow Up

30 Unforgettable Books Every Parent Should Read To Their Kids Before They Grow UpFamilyLifestyleby Carmen Sakurai The comfort and nurturing one-on-one attention from parents while

2015-03-07 22:04:29 2177

转载 20 Books Everyone Should Read Before Age 40

Books are wonderful things. Information, entertainment, wisdom and imagination all wrapped up in a nice little bundle of pages… or an electronic file as the case may be.But there are so many. Millio

2015-03-07 21:27:01 1009

原创 几个比较强大的工具

1.KDE System Guard - Real-time Systems Reporting and Graphing (KSysguard)2.   ntop: the best tool to see network usage in a way similar to what top command does for processes i.e. it is networ

2015-03-07 01:39:45 526

转载 Linux Kernel Programming–Linked List

Linux kernel has linked-list as a built-in data structure defined in /lib/modules/$(uname -r)/build/include/linux/list.h. Compared with common implementations of linked list, the Linux kernel version

2015-03-06 09:08:05 970

原创 查看linux的 default gateway

1. $ route -nKernel IP routing tableDestination Gateway Genmask Flags Metric Ref Use Iface0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 wlan017

2015-03-05 23:36:31 4720

转载 Soft Irqs And Tasklets

Tasklets are implemented on top of softirqs. In kernel source code, both SoftIrq andTaskLet are displayed in "softirq"statically allocated, while tasklets can also be allocated and initialized

2015-03-05 21:26:15 974

原创 中断处理函数和可重入特性

Interrupt handlers in Linux need not be reentrant. When a given interrupt handler is executing, the corresponding interrupt line is masked out on all processors, preventing another interrupt on the sa

2015-03-05 00:27:56 1702

原创 查找网卡所用的驱动

方法1:$ sudo lshw -C network *-network description: Ethernet interface product: 82579LM Gigabit Network Connection vendor: Intel Corporation physical id: 1

2015-03-04 22:42:48 987

转载 A new I/O memory access mechanism

Most reasonably current cards for the PCI bus (and others) provide one ormore I/O memory regions to the bus. By accessing those regions, theprocessor can communicate with the peripheral and make thing

2015-03-01 13:28:52 521

原创 求每个元素之和为最大的给定数组的子数组

给定的数组,元素可能为正或者为负方法 1. broute-force这个是最容易想到的方法,就是把每个可能的子数组列出来,计算出元素之和,然后把最大的挑出来。显然,这个算法的时间复杂度为 O(n^2)struct tuple FindMaxSubArray(int *array, int size){ struct tuple t; t.sum = INT_MIN;

2015-03-01 00:16:46 737

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除