`
yanlijun250
  • 浏览: 750119 次
文章分类
社区版块
存档分类
最新评论
文章列表
问题定义: 输入:输入一个由n个元素构成的集合a和一个数值i,且1<= i <= n。 输出:一个元素x属于a,它比前面i-1个元素都大,也就是第i个最小的元素。 特列:寻找中位数问题。 随机选择的时间复制度为O(n)。 代码如下: /* *Copyright(c) Computer Science Department of XiaMen University * *Authored by laimingxing on: 2012年 03月 02日 星期五 00:47:43 CST * * @desc: * * @history */ #inc ...
问题定义: 问题定义比较复杂,建议看《算法导论》里的线性规划一章。单纯型算法用于求解如下这类问题: 例: 求等式的最小值: -2X1– 3X2 且自变量满足如下约束: X1 + X2 = 7 X1 – 2X2<= 4 X1>= 0 将约束等式转换为标准型: 标准型的条件: 1. 求目标函数的最大值 2. 每个自变量都大于等于零(非负约束) 3.约束不等式,只有最小化约束 转换结果如下: max 2X1 – 3X2 + 3X3 并且满足: X1 + X2- X3 <= 7 -X1 – X2+ X3 <= -7 ...
问题定义: 如果地板的宽度是针的两倍,则向地板投针,与地板缝隙相交的概率为1/π 参考资料: http://www.hudong.com/wiki/Buffon%E6%8A%95%E9%92%88%E9%97%AE%E9%A2%98 程序如下: #include<stdio.h> #include<ctime> #include<cstdlib> #include <math.h> // 设地板的宽度为2,针的长度为1 void rand_seed(); float Randomf( float a, float b); int ...
#include <sys/syscall.h> LOGI(" TID: %d, PID: %d", code, syscall(__NR_gettid), syscall(__NR_getpid); LOGI(" TID: %d, PID: %d", code, syscall(224), syscall(20); ----- 参考:http://my.huhoo.net/archives/2009/10/linuxid.html http://www.oklinux.cn/html/developer/other/20080814/59 ...
在linux中,线程与进程最大的区别就是是否共享同一块地址空间,而且共享同一块地址空间的那一组线程将显现相同的PID号。 在实际编程应用中,我们会很容易发现并证明,一组同源线程的PID都是一样的,但它们的PID真的一样么? 在linux中,线程的创建和普通进程的创建类似,只不过在调用clone()的时候需要传递一些参数标志来指明需要共享的资源: clone(CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND,0)
从由汉字,大小写英文,数字组成的语句中分离汉字: public static void regxChinese() { String source = "桑德斯ABdD3ddd5222字符串转换健康康可能34f丰富4f成小写dx5kljfdsljDSknf943立即地方立即的ddd顶顶顶3"; String reg_charset = "([a-z]*)([A-Z]*)([0-9]*)([\u4E00-\u9FA5]*)"; Pattern p = Pattern.compile(reg_ch ...
cat:由第一行开始显示文本内容 tac:从最后一行开始显示文本内容 nl:显示的时候,顺便输出行号 more:一页一页地显示文件内容 less:与more类似,但是比more更好的是,可以往前翻页 head:只看头几行 tail:只看结尾几行 od:以二进制的方式读取文件内容 cat [-AbEnTv] -A 相当于-vET的整合参数,可列出一些特殊字符,而不是空白而已 -b 列出行号,但是不包括空白行 -E 将结尾的断行符用$显示出来 -n 打印出行号,连同空白行一起 -T 将[Tab]按键显示出来 -v 列出一些看不出来的特色字符 tac( cat 的re ...
chgrp : change the groupchown: change the ownerchmod: change the permission chgrp [-R] dirname/filename...... For example: chgrp users install.log chown [-R] username dirname/filename For example: chown root:root install.log chmod [-R] xyz dirname/filename r:4 w:2 x:1 For example: chmod 7 ...
IPhone的成功,其支持多点触摸的电容屏触摸技术有不小的功劳,最近进行地图软件的移植开发,对多点触控进行了一些研究,在这里整理一下开发心得同大家分享。 老的电阻式触摸屏(就是不支持多点触摸,需要用触控笔操作的),相对于鼠标的使用行为,其实差别不大,所以在windows消息里面,对触控消息,都还是沿用老的mousedown,mouseup,mousemove这三个函数处理,唯一和鼠标不一样的,就是 1. 没有鼠标左键右键的区分 2. 只要有mousemove消息,肯定先有mousedown,触摸屏上移动肯定要先点击了 但是总体而言,单点触摸屏的消息机制 ...
server { ... location / { #启用rewriteif (!-e $request_filename) { rewrite ^([_0-9a-zA-Z-]+)?(/wp-.*) $2 last; rewrite ^([_0-9a-zA-Z-]+)?(/.*\.php)$ $2 last; rewrite ^ /index.php last; } } ... } #apache 启用 rewrite module LoadModule rewrite_module /usr/lib/ ...
问题描述: 代码如下: /* * *Declaration:The author of <<Accelerated C++>> has wrote in the end of that book: As you look for reading materimal, keep in mind that books on the shelf do not make you a better programmer. Ultimately, the only way to improve your programming is to write programs. ...
代码如下: /* * *Declaration:The author of <<Accelerated C++>> has wrote in the end of that book: As you look for reading materimal, keep in mind that books on the shelf do not make you a better programmer. Ultimately, the only way to improve your programming is to write programs. >这 ...
此乃字符串处理的典型例题,不知到为什么在Ubuntu下提示没有strrev函数,可能是编译器的问题吧。 代码如下: /* * *Declaration:The author of <<Accelerated C++>> has wrote in the end of that book: As you look for reading materimal, keep in mind that books on the shelf do not make you a better programmer. Ultimately, the only way to ...
代码如下: /* * *Declaration:The author of <<Accelerated C++>> has wrote in the end of that book: As you look for reading materimal, keep in mind that books on the shelf do not make you a better programmer. Ultimately, the only way to improve your programming is to write programs. >这些程 ...
程序如下: /* * *Declaration:The author of <<Accelerated C++>> has wrote in the end of that book: As you look for reading materimal, keep in mind that books on the shelf do not make you a better programmer. Ultimately, the only way to improve your programming is to write programs. >这 ...
Global site tag (gtag.js) - Google Analytics