自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(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 382

原创 linux达人养成计划 (挂载&查看用户的登录信息)

挂载就是分配盘符。root等自动挂载,但u盘不能自动挂载,windows能自动挂载。mount 查看系统中已经挂载的系统sda5根目录proc  sysfs 内存自动挂载/dev/sda1设备文件名   on   /boot挂载点  /dev/sda2                         on  /homemount -a 根据文件自动挂载一遍/et

2014-12-19 11:30:34 284

原创 压缩和解压缩& 关机重启

压缩格式: zip(和windows的zip一样)  zip+file.zip(压缩成该文件)+源文件  空压缩文件比源文件大,因为其中包含了压缩格式的换算。-r 压缩目录, unzip解压缩。.gz格式(windows可以实现解压缩) gzip + file 会自动生成源文件。 gzip -c 源文件 > 压缩文件  gzip -r 把目录中的文件压缩,但是不会把这个文件打包。 gzip -

2014-12-19 10:40:36 370

原创 获取帮助

grep -v 搜索不包含某个关键字find是完全匹配,grep是包含匹配man -f =  whatis 可以看到有几级帮助sbin 超级用户才能用bin 普通用户就行man -k = apropos 查看在帮助文档中含有某关键字的文档shell是linux的壳,要把命令传进内核才知道,但是内核只知道二进制,所以shell就做中介,一个交互的接口。有些

2014-12-19 10:38:49 220

原创 文件搜索命令

find 耗费资源locate 搜索速度快locate +file /val/lib/mlocate 保存其数据库 一天更新一次 所以新建的不能马上找到,updatedb 强制更新数据库。如果同时生成两个相同名的文件按照/ect/updatedb.conf进行搜索 (whereis  which)该配置文件内容PRUNE_BIND_MOUNTS="YES" 开启

2014-12-19 09:01:06 185

原创 linux达人养成计划(ln)

ln     硬链接ln -s 软链接先去搜索分区索引表,通过inode号查找。索引表中的信息:存的地址,时间和id号。硬链接: 比如sb和bs有相同的id号,文件的索引号和存储位置一样。把任何一个删了都不影响另一个,可以想象成一间教室的两扇门。             问题是不能跨分区;只能针对文件不能针对目录。ln  root/file   /tmp/file.ha

2014-12-18 23:02:37 211

原创 linux达人养成计划(常见目录)

/sbin  root权限/bin/boot  启动目录 用户的启动数据/dev  特殊文件保存目录/etc 保存配置文件/lib  函数库的保存目录  用的时候调用/media  /mnt  /misc:/挂载  必须挂在在空目录下/proc /sys不能直接操作,数据都存在内存中。第启动就小时了,另外太小了。/usr/ bin/var/limux

2014-12-18 23:01:22 213

原创 linux达人养成计划I

[root@localhost ~]#root:登录用户localhost: 主机名~ : 当前所在目录#:超级用户$: root 的家目录: /root命令 [选项] [参数]注意:当有多个选项时,可以写在一起简化选项和完整选项  -a == --allls  -a 所有 ,显示隐藏文件 ls -l  详细信息 -rwxw--w

2014-12-18 22:53:12 228

原创 给定未排序的数组,请给出方法找到最长的等差数列

#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 352

转载 elment of programming interview 9.10 the exterior of binary tree (输出二叉树的外围) 题解

2014-07-13 10:17:17 230

原创 面试题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 310

原创 面试题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 597

原创 数组配对

给定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 497

原创 局部最大值

#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 809

原创 二叉搜索树两点之和等于给定值

#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 387

原创 矩阵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 1195

原创 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 315

原创 [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 264

原创 Write a function that computes log2() using sqrt()

Write a function that computes log2() using sqrt()by lyydouble l = 足够小 ,r = 足够大, lm = 2^l, rm = 2^rwhile(r - l > eps){      double mid = (l + r) * .5;      double midm = sqrt(lm * rm);  

2014-07-02 20:56:50 411

空空如也

空空如也

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

TA关注的人

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