- 博客(19)
- 收藏
- 关注
原创 linux达人养成计划I shell脚本
shell用户和内核交互的接口,接受命令,或者是翻译器。 如 ls,shell接受命令,转化成二进制,内核识别到改二进制,调用硬件、显示器,再通过shell传给用户。 1. boursh shell: ksh sh psh bash(最常用的) 2. CShell: BSD的unix shell linux和unix的主要区别 echo -e 识别命令 echo
2014-12-19 13:05:53
410
原创 linux达人养成计划 (挂载&查看用户的登录信息)
挂载就是分配盘符。root等自动挂载,但u盘不能自动挂载,windows能自动挂载。 mount 查看系统中已经挂载的系统 sda5根目录 proc sysfs 内存自动挂载 /dev/sda1设备文件名 on /boot挂载点 /dev/sda2 on /home mount -a 根据文件自动挂载一遍 /et
2014-12-19 11:30:34
309
原创 压缩和解压缩& 关机重启
压缩格式: zip(和windows的zip一样) zip+file.zip(压缩成该文件)+源文件 空压缩文件比源文件大,因为其中包含了压缩格式的换算。-r 压缩目录, unzip解压缩。 .gz格式(windows可以实现解压缩) gzip + file 会自动生成源文件。 gzip -c 源文件 > 压缩文件 gzip -r 把目录中的文件压缩,但是不会把这个文件打包。 gzip -
2014-12-19 10:40:36
403
原创 获取帮助
grep -v 搜索不包含某个关键字 find是完全匹配,grep是包含匹配 man -f = whatis 可以看到有几级帮助 sbin 超级用户才能用 bin 普通用户就行 man -k = apropos 查看在帮助文档中含有某关键字的文档 shell是linux的壳,要把命令传进内核才知道,但是内核只知道二进制,所以shell就做中介,一个交互的接口。 有些
2014-12-19 10:38:49
237
原创 文件搜索命令
find 耗费资源 locate 搜索速度快 locate +file /val/lib/mlocate 保存其数据库 一天更新一次 所以新建的不能马上找到,updatedb 强制更新数据库。 如果同时生成两个相同名的文件 按照/ect/updatedb.conf进行搜索 (whereis which) 该配置文件内容 PRUNE_BIND_MOUNTS="YES" 开启
2014-12-19 09:01:06
199
原创 linux达人养成计划(ln)
ln 硬链接 ln -s 软链接 先去搜索分区索引表,通过inode号查找。索引表中的信息:存的地址,时间和id号。 硬链接: 比如sb和bs有相同的id号,文件的索引号和存储位置一样。把任何一个删了都不影响另一个,可以想象成一间教室的两扇门。 问题是不能跨分区;只能针对文件不能针对目录。 ln root/file /tmp/file.ha
2014-12-18 23:02:37
224
原创 linux达人养成计划(常见目录)
/sbin root权限 /bin /boot 启动目录 用户的启动数据 /dev 特殊文件保存目录 /etc 保存配置文件 /lib 函数库的保存目录 用的时候调用 /media /mnt /misc:/挂载 必须挂在在空目录下 /proc /sys不能直接操作,数据都存在内存中。第启动就小时了,另外太小了。 /usr/ bin /var/ limux
2014-12-18 23:01:22
228
原创 linux达人养成计划I
[root@localhost ~]# root:登录用户 localhost: 主机名 ~ : 当前所在目录 #:超级用户 $: root 的家目录: /root 命令 [选项] [参数] 注意:当有多个选项时,可以写在一起 简化选项和完整选项 -a == --all ls -a 所有 ,显示隐藏文件 ls -l 详细信息 -rwxw--w
2014-12-18 22:53:12
243
原创 给定未排序的数组,请给出方法找到最长的等差数列
#include #include int max_len = 1; //int array[]={2, 3 ,5 ,7 ,8 ,4 ,9, 5 ,10, 6 }; int array[]={1, 1 ,1 ,2, 2, 3 ,3, 4, 4, 5}; #define SIZE(a) sizeof(a)/sizeof(a[0]) int map[100][100];
2014-07-28 22:16:05
372
转载 elment of programming interview 9.10 the exterior of binary tree (输出二叉树的外围) 题解
2014-07-13 10:17:17
253
原创 面试题12:求一维数组中最小的k个数 top k I
#include using namespace std; int part(int a[], int start, int e) { int i=start, j=e; int pilot=a[i]; // cout while(i { // cout while(i=pilot) j--;
2014-07-10 18:16:59
326
原创 面试题10:数位重组
给定两个数组表示的整数,如x=1234={1,2,3,4} y=2410={2,4,1,0} 返回第一个整数的重组之后的值最接近第二个整数,并且大于第二个整数。假设两个数组的大小相同。 上例返回{2,4,1,3} 4,3,2,1 --》 2,4,1,0 ====2,4,1,3 #include #include #include using namespace std;
2014-07-10 18:16:03
626
原创 数组配对
给定N个整数,N为偶数,是否能浙大N/2对,使得每对和能被k整除。注意:每个元素只能出现在一个配对中。 方法:统计各个数modK之后的结果,对余数是0和k/2的情况进行特殊处理 #include #include #include using namespace std; bool match(int A[], int n, int k) { int
2014-07-10 18:12:01
518
原创 局部最大值
#include #include using namespace std; //输入一个数组和一个窗口,输出一个数组代表移动窗口的最大值 struct node { int val; int index; node(int v, int i):val(v),index(i){} }; struct cmp { bool operator
2014-07-08 23:03:55
840
原创 二叉搜索树两点之和等于给定值
#include #include #include #include #include using namespace std; struct tree { int val; tree* left; tree* right; tree(int v, tree* l, tree* r):val(v),left(l),right(r){
2014-07-08 19:01:34
421
原创 矩阵topK 给一个矩阵,各行各列均有序,求第k小值。(k大的值)
k小从左上角入手,k大从右下角入手。 几个注意点:1. cmp必须是类或结构体,不能是函数 2. priority_queue大小相反 3. 定义cell结构体的功能是每次都能找到数字在数组中的位置。和滑雪类似。 #include #include #include #include using namespace std; struct cell {
2014-07-08 18:17:59
1223
原创 Given a list of presentations with begin and end time that all need to use a conference room.
#include #include #include #include #include using namespace std; struct interval { int s; int e; interval(int ss,int ee):s(ss),e(ee){} }; int maxal(vector & v) { in
2014-07-03 14:57:06
324
原创 [Twitter] Given a matrix with all elements sorted on each individual row and column find
每次找到每行要比较的最小的列。 逐行比较 #include #include #include using namespace std; int k_thsmall(vector > a, int k) { int n=a.size(); int m=a[0].size(); vector minCol(n, 0); minC
2014-07-02 20:59:19
273
原创 Write a function that computes log2() using sqrt()
Write a function that computes log2() using sqrt() by lyy double l = 足够小 ,r = 足够大, lm = 2^l, rm = 2^r while(r - l > eps) { double mid = (l + r) * .5; double midm = sqrt(lm * rm);
2014-07-02 20:56:50
430
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅