- 博客(21)
- 资源 (1)
- 收藏
- 关注
原创 shell面试题
得到当前的日期,时间,用户名和当前工作目录#! /bin/shecho "hello $LOGNAME"echo "Current date is `date`"echo "User is `who i am`"echo "Current directory `pwd`"$LOGNAME date who i am pwd “命令展开,Shell先执行该命令,然后将输出结果立刻代换到
2016-05-02 00:04:08
236
原创 find命令
-namefind ./ -name “*.c” 文件名 -type文件类型 find ./ -type f f:普通文件 d:目录 c:字符 p:管道 s:套接字 b:块文件 l:链接文件-maxdepth指定搜索深度(需求强烈)1 深度一级-size大小 缺省大小:一个扇区521B字节(0.5K)(文件22个字节在物理内存上也占一个扇区,这是最小单位)对于10566大小的
2016-05-01 17:45:58
185
原创 简单的makefile
概念makefile理解: makefile关系到了整个工程的编译规则。一个工程的源文件不计其数,其按类型、功能、模块分别放在若干目录中,makefile定义了一系列的规则来指定,那些文件需要先编译,哪些文件需要后编译,哪些文件需要更新编译,甚至于进行更复杂的功能操作,因此makefile像shell脚本一样,其中可以执行系统操作的命令。 好处 自动化编译,一旦写好,只需要一个make命令,整
2016-04-30 19:23:53
275
原创 shell脚本
开头 #! /bin/bash #! /bin/sh执行shell脚本 - . a.sh - chmod +x a.sh ./a.sh - /bin/sh ./a.sh - source ./a.sh变量1.环境变量 环境变量可以从父进程传给子进程,因此Shell进程的环境变量可以从当前Shell进程传给fork出来的子进程。用printenv命令可以显示当前She
2016-04-29 23:12:23
250
原创 关于二维数组与数组指针
//二维数组int a[2][3]={1,2,3,4,5,6};//指针数组int (*b)[3]=NULL;//建立关系b=a;//各步长sizeof(a);//4*3*2=24sizeof(b);//32位系统下4sizeof(a[0]);//4*3=12;sizeof(a[0][0]);//4sizeof(b[0]);//b[0]与a[0]等价 12sizeof(b[0
2016-03-26 23:50:24
187
原创 Binary Tree Inorder Traversal
单词: inorder 中序 Traversal 遍历代码:#include <iostream>#include<vector>#include<stack>using namespace std;//数的结构体typedef struct _BiNode{ //数据 int data; //左孩子 struct _BiNode* lChild;
2016-03-25 23:22:03
156
原创 Binary Tree Preorder Traversal
单词: Preorder 前序,先序 Traversal 遍历 思路: 栈容器 先将根压入栈,用节点保存头元素,当栈容器不为空时 //遍历 while(!B.empty()) { //节点保存头元素; p=B.top(); //将头元素的数据压入vector容器; result.push_back(p->data); //头元素出栈;
2016-03-24 22:21:14
221
原创 Remove Duplicates from Sorted List
说明: Given a sorted linked list, delete all duplicates such that each element appear only once. For example, Given 1->1->2, return 1->2. Given 1->1->2->3->3, return 1->2->3. 代码:/*******************
2016-03-21 12:41:59
186
原创 Partition List
单词:partition 分割 说明: Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x. You should preserve the original relative order of
2016-03-20 23:37:41
205
原创 Reverse Linked List II
说明: Reverse a linked list from position m to n. Do it in-place and in one-pass. For example: Given 1->2->3->4->5->nullptr, m = 2 and n = 4, return 1->4->3->2->5->nullptr. Note: Given m, n satisfy t
2016-03-20 00:14:47
186
原创 Add Two Numbers
题意: You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a
2016-03-18 23:56:50
178
原创 Remove Duplicates from Sorted Array II
思路:加入一个变量来记录元素出现的次数方法一:class A{public: int Remove(int *a,int len) { if(a==NULL||len<0) return 0; if(len<=2) return len; int index=2; f
2016-03-18 15:58:44
176
原创 Remove Duplicates from Sorted Array
单词: duplicate相同的数 Sort有序 Array数组思路: 1.Allocate extra space for another array#include <iostream>#include <vector>using namespace std;class SortedArray{public: void Print(vector<int> &nums
2016-03-18 11:31:44
175
原创 递归调用
#include <stdio.h>int f(int n){ if(n==1||n==0) return 1; else return f(n-1)+f(n-2);}int main(){ int num=f(4); printf("%d\n",num); return 0;}递归调用思路图解:
2016-03-11 23:07:39
180
原创 如何用两个栈实现一个队列(思路)(欢迎提意见)
思路:1.栈的规律是先进后出而队列的规律是先进先出2.pop和push实现 现提供两个栈,对于队列向里压数据的时候,可以当作向第一个栈里压数据, 而当向外出队列的时候(先进先出),这时把第一个栈的数据全部压到 第二个栈里,从第二个栈里往外压数据,就是最先进队列的那个元素3.back和front实现 1)front是获得头元素,即最先进队列的那个元
2016-03-10 21:09:45
692
原创 杨辉三角
#include using namespace std;int main(){ cout int n=0; cin>>n; int a[n][n]={0}; for(int i=0;i { for(int j=0;j { if(j==0||j==i)
2016-03-10 20:51:34
176
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人