上一页 1 ··· 9 10 11 12 13
摘要: (1)VAR=value(2)read VAR(3)VAR=`date` 或 VAR=$(date)如果字符串里包含空格,就必须用引号把他们括起来,此外等号两边不能有空格var=“hello world” 阅读全文
posted @ 2013-04-15 16:33 OpenSoucre 阅读(160) 评论(0) 推荐(0) 编辑
摘要: ls - l > output.txt # 把ls命令的输出保存到output.txt中ls - l >> output.txt # 把ls命令的附加到output.txt中利用linux的通用“回收站” /dev/null 来有效的丢弃所有的输出信息ls -l > /dev/nullmore < input.txt #重定向输入 阅读全文
posted @ 2013-04-15 16:19 OpenSoucre 阅读(222) 评论(0) 推荐(0) 编辑
摘要: /bin/bash --version 阅读全文
posted @ 2013-04-15 16:07 OpenSoucre 阅读(1110) 评论(0) 推荐(0) 编辑
摘要: .a代表传统的静态函数库.so代表共享函数库函数库通常同时以静态库和共享库两种格式存在,你可以使用ls /usr/lib命令查看,你可以通过给出完整的库文件路径名或用-l标志来告诉编译器要搜索的库文件gcc -o fred fred.c /usr/lib/libm.a 阅读全文
posted @ 2013-04-15 16:03 OpenSoucre 阅读(439) 评论(0) 推荐(0) 编辑
摘要: grep 全局正则表达式及打印,在一个或多个文件中搜索是否包含某给定的字符串。grep [options] pattern [file-list]options: 选项 -r :file-list可以包含要搜索的目录,递归的搜索file-list中的目录,处理目录中的文件 选项 -v :用来搜索不包含匹配字符串的行 选项 -n :用来显示每行行号 选项 -w :pattern必须与整个字匹配 选项 -i :使得搜索不区分大小写 选项 -c :显示每个文件包含匹配的数目 选项 -f :用来搜索某个文件中的每个匹配 选项 -h :当搜索多个文件时,在每行不显示文件名 选项 -l... 阅读全文
posted @ 2013-04-15 15:52 OpenSoucre 阅读(223) 评论(0) 推荐(0) 编辑
摘要: 在linux中,对c语言来说,这些头文件几乎在/usr/include目录及子目录中,那些依赖特定linux版本的头文件也可在目录/usr/include/linux中在调用c语言编辑器时,你可以使用-I标志来包含保存在子目录或非标准位置中的头文件,如gcc -I /usr/xxx/include fred.c他指示编译器不仅在标准位置,也在/usr/xxx/include目录中查找程序fred.c中包含的头文件 阅读全文
posted @ 2013-04-15 15:17 OpenSoucre 阅读(1757) 评论(0) 推荐(1) 编辑
摘要: 1 #include <iostream> 2 #include <vector> 3 #include <algorithm> 4 #include <map> 5 6 using namespace std; 7 8 int main(){ 9 int n;10 cin >> n;11 map<int,int> id;12 for(int i = 0; i <n; i ++ ){13 int a;14 cin >>a;15 if(id.find(a) == id.end()) id[a] = 1;16 阅读全文
posted @ 2013-04-14 21:01 OpenSoucre 阅读(190) 评论(0) 推荐(0) 编辑
摘要: 1 getline(cin,input);2 cin.clear();3 cin.sync();4 getline(cin,input); 阅读全文
posted @ 2013-04-12 10:49 OpenSoucre 阅读(1904) 评论(0) 推荐(0) 编辑
摘要: 1 #include <iostream> 2 #include <vector> 3 4 using namespace std; 5 6 int main(){ 7 int n; 8 while(cin >> n && n){ 9 vector<int> a(n);10 for(int i = 0; i < n; i ++ ) cin >> a[i];11 int cnt = 0;12 while(1){13 int k;14 for(k = 0; k <... 阅读全文
posted @ 2013-04-11 12:10 OpenSoucre 阅读(139) 评论(0) 推荐(0) 编辑
摘要: 二叉树二叉查找树(BST)笛卡尔树MVP树Top treeT树自平衡二叉查找树AA树AVL树左倾红黑树红黑树替罪羊树伸展树树堆节点大小平衡树B树B+树B*树Bx树UB树2-3树2-3-4树(a,b)-树Dancing treeH树Trie后缀树基数树三叉查找树X-快速前缀树Y-快速前缀树二叉空间分割(BSP)树四叉树八叉树k-d树隐式k-d树VP树非二叉树指数树融合树区间树PQ树Range treeSPQR树Van Emde Boas tree空间数据分割树R树R*树R+树X树M树线段树希尔伯特R树优先R树其他树堆散列日历散列树Finger treeOrder statistic treeMe 阅读全文
posted @ 2013-04-10 23:19 OpenSoucre 阅读(237) 评论(0) 推荐(0) 编辑
摘要: 1 #include <iostream> 2 #include <vector> 3 #include <cstdio> 4 #include <cstring> 5 #include <algorithm> 6 using namespace std; 7 8 int main(){ 9 vector<string> first,second;10 string a,b;11 bool exitFlag = false;12 while(1){13 getline(cin,a);14 if(a == "#&q 阅读全文
posted @ 2013-04-10 23:08 OpenSoucre 阅读(154) 评论(0) 推荐(0) 编辑
摘要: 最长公共子序列的变形题,算法导论公共子序列后的练习题有题是类似的注意在公共子序列中要判断a[i]和b[j]相等,而此题是考虑相似,不要求相等 1 #include <iostream> 2 #include <vector> 3 #include <algorithm> 4 #include <cstdio> 5 #include <cstring> 6 #include <string> 7 #include <map> 8 9 #define MAX 100 + 510 using namespace st 阅读全文
posted @ 2013-04-10 22:13 OpenSoucre 阅读(212) 评论(0) 推荐(0) 编辑
摘要: 1 #include <iostream> 2 #include <vector> 3 #include <algorithm> 4 #include <string> 5 #define MAX 200 6 using namespace std; 7 8 struct stu{ 9 int id;10 string time;11 };12 13 bool cmp(stu a,stu b){14 return a.time<b.time;15 }16 17 int main(){18 int n;19 while(cin >> 阅读全文
posted @ 2013-04-10 17:22 OpenSoucre 阅读(152) 评论(0) 推荐(0) 编辑
摘要: 转换成最大子序列和 1 #include <iostream> 2 #include <vector> 3 #include <algorithm> 4 #include <cstring> 5 6 #define MAX 200 7 using namespace std; 8 9 int main(){10 int n;11 while(cin >>n){12 int arr[MAX][MAX]={0};13 for(int i = 1; i<= n; i ++ ){14 for(int j = 1; j <= n.. 阅读全文
posted @ 2013-04-10 16:48 OpenSoucre 阅读(127) 评论(0) 推荐(0) 编辑
摘要: 1 #include <iostream> 2 #include <vector> 3 #include <algorithm> 4 #include <map> 5 #include <string> 6 7 using namespace std; 8 9 struct matrix{10 int row,col;11 };12 13 int main(){14 int n;15 cin >>n;16 map<string,matrix> a;17 for(int i = 0;i < n; i ++ 阅读全文
posted @ 2013-04-10 16:16 OpenSoucre 阅读(200) 评论(0) 推荐(0) 编辑
摘要: 计算几何基础问题,具体可以参考算法导论p577,确定两个线段是否相交 1 #include <iostream> 2 #include <vector> 3 #include <algorithm> 4 5 using namespace std; 6 7 struct point{ 8 double x,y; 9 };10 11 struct segment{12 point p1,p2;13 };14 15 double direction(point p1, point p2, point p3){16 return (p2.x-p1.x)*(p3.y 阅读全文
posted @ 2013-04-10 14:51 OpenSoucre 阅读(155) 评论(0) 推荐(0) 编辑
摘要: 最长递增子序列 1 #include <iostream> 2 #include <vector> 3 #include <algorithm> 4 #include <cstring> 5 #define MAX 1001 6 using namespace std; 7 8 int dp[MAX]; 9 10 int main(){11 int n;12 while(cin >> n && n){13 int player[MAX];14 for(int i = 1 ; i <= n ; i ++ ) cin 阅读全文
posted @ 2013-04-10 13:54 OpenSoucre 阅读(139) 评论(0) 推荐(0) 编辑
摘要: 1 #include <iostream> 2 #include <vector> 3 #include <algorithm> 4 #include <cstring> 5 6 #define MAX 1001 7 using namespace std; 8 9 struct cloth{10 int xi,yi,ci;11 };12 int dp[MAX][MAX]={0};13 14 int main(){15 int T;16 cin >> T;17 while(T--){18 int N,X,Y;19 cin >.. 阅读全文
posted @ 2013-04-09 23:18 OpenSoucre 阅读(170) 评论(0) 推荐(0) 编辑
摘要: 此题一定要注意输入是 n || m 不是 n&&m, 就因为这个WA了几次此题是01背包的增加型,不要完全套01背包,由于是概率所以要考虑乘法,题目要求的是至少被录取,根据概率论,求其反面简单 1 #include <iostream> 2 #include <vector> 3 #include <algorithm> 4 #include <cstdio> 5 #include <cstring> 6 7 using namespace std; 8 9 int main(){10 int n,m;11 while 阅读全文
posted @ 2013-04-09 21:43 OpenSoucre 阅读(147) 评论(0) 推荐(0) 编辑
摘要: 像下面代码直接利用二进制求解多重背包会超时 1 #include <iostream> 2 #include <cstdio> 3 #include <cstdlib> 4 #include <vector> 5 #include <algorithm> 6 7 using namespace std; 8 9 int main(){10 int n,m;11 while(cin>>n>>m && n && m){12 vector<int> A(n),C(n);13 阅读全文
posted @ 2013-04-09 17:34 OpenSoucre 阅读(177) 评论(0) 推荐(0) 编辑
摘要: 多维费用背包 1 #include <iostream> 2 #include <vector> 3 #include <algorithm> 4 5 using namespace std; 6 7 struct good { 8 int a,b,val; 9 };10 11 int main(){12 int n,v1,v2,k;13 while(cin >> n>>v1>>v2>>k){14 vector<good> commodity(n);15 for(int i = 0; i < 阅读全文
posted @ 2013-04-09 15:39 OpenSoucre 阅读(231) 评论(0) 推荐(0) 编辑
摘要: 利用传统的完全背包解法会超时,下面代码超时 1 #include <iostream> 2 #include <vector> 3 #include <algorithm> 4 5 #define INF 1<<30 6 using namespace std; 7 8 int main(){ 9 int T;10 cin >> T;11 while(T--){12 int E,F;13 cin >>E>>F;14 int pigWeight =F-E;15 int n;16 cin >... 阅读全文
posted @ 2013-04-08 23:03 OpenSoucre 阅读(161) 评论(0) 推荐(0) 编辑
摘要: 此题实在无语就因为把判断输入条件写成 n!=-1就WA了几次,自己以后要多注意 1 #include <iostream> 2 #include <vector> 3 #include <algorithm> 4 #include <cstdio> 5 #include <cmath> 6 7 using namespace std; 8 9 int main(){10 int n;11 while(cin >> n && n >= 0){12 int v,num,sumV = 0;13 vector 阅读全文
posted @ 2013-04-08 22:22 OpenSoucre 阅读(148) 评论(0) 推荐(0) 编辑
摘要: 1 #include <iostream> 2 #include <vector> 3 #include <algorithm> 4 5 using namespace std; 6 7 int main(){ 8 int n; 9 while(cin >>n && n){10 vector<int> food(n);11 for(int i = 0; i < n; i ++ ) cin >> food[i];12 int price;13 cin >> price;14 if(price 阅读全文
posted @ 2013-04-08 21:25 OpenSoucre 阅读(166) 评论(0) 推荐(0) 编辑
摘要: 1 #include <iostream> 2 #include <vector> 3 #include <algorithm> 4 5 using namespace std; 6 7 int main(){ 8 int T; 9 cin >> T;10 while(T--){11 int N, V;12 cin >> N>>V;13 vector<int> value(N), volume(N);14 for(int i = 0; i < N; i ++) cin >>value[i];1 阅读全文
posted @ 2013-04-08 21:01 OpenSoucre 阅读(134) 评论(0) 推荐(0) 编辑
摘要: 每种物品只有一件的是01背包每种物品有无限件的是完全背包每种物品有有限件的是多重背包 (利用二进制思想,转化为01背包)每种物品有多重价值的是二维费用背包这几种背包基本的动态转移方程 dp[i][j] 从前i件物品选择若干物品装到容量为j的背包中产生的最大价值 dp[i][j] = max{ dp[i-1][j] , dp[i][j - c[i] ] + w[i] } 阅读全文
posted @ 2013-04-08 20:43 OpenSoucre 阅读(271) 评论(0) 推荐(0) 编辑
摘要: 1 #include <iostream> 2 #include <vector> 3 #include <algorithm> 4 #include <cstring> 5 #include <cstdio> 6 7 using namespace std; 8 9 int main(){10 int n;11 cin >>n;12 vector<int> stone(n+1,0);13 int sum = 0;14 for(int i = 1; i <= n; i ++){15 cin >> 阅读全文
posted @ 2013-04-08 19:33 OpenSoucre 阅读(1525) 评论(0) 推荐(1) 编辑
摘要: 1 #include <iostream> 2 #include <algorithm> 3 #include <vector> 4 #include <cstdio> 5 6 #define MAX 20 + 3 7 8 using namespace std; 9 10 const int dx[] = {-1,1,0,0};11 const int dy[] = {0,0,-1,1};12 13 int main(){14 int n,m;15 while( cin>>n>>m && n && 阅读全文
posted @ 2013-04-07 20:20 OpenSoucre 阅读(207) 评论(0) 推荐(0) 编辑
摘要: 贪心算法 1 #include <iostream> 2 #include <vector> 3 #include <algorithm> 4 5 using namespace std; 6 7 struct Job{ 8 int j,b; 9 bool operator < (const Job& x) const {10 if( j == x.j ) return b < x.b;11 return j > x.j;12 }13 };14 15 int main(){16 int n,iCase = 0;17 w... 阅读全文
posted @ 2013-04-06 23:44 OpenSoucre 阅读(244) 评论(0) 推荐(0) 编辑
摘要: 贪心的思想 1 #include <iostream> 2 #include <algorithm> 3 #include <vector> 4 5 using namespace std; 6 7 int main(){ 8 int n,m; 9 while(cin >> n>>m && n && m){10 vector<int> heads(n),knights(m);11 for(int i = 0; i < n; i ++ ) cin >> heads[i];12 阅读全文
posted @ 2013-04-06 22:55 OpenSoucre 阅读(163) 评论(0) 推荐(0) 编辑
摘要: 基于自底向上的动态规划 1 #include <iostream> 2 #include <cstdio> 3 #include <algorithm> 4 #include <vector> 5 #include <cstring> 6 #include <string> 7 8 #define MAX 1000 9 using namespace std;10 11 12 int a[MAX] = {0}, dp[MAX][MAX] = {0},path[MAX][MAX] = {0}, n;13 14 void ma 阅读全文
posted @ 2013-04-06 20:19 OpenSoucre 阅读(199) 评论(0) 推荐(0) 编辑
摘要: 1 #include <iostream> 2 #include <map> 3 #include <vector> 4 #include <sstream> 5 #include <string> 6 using namespace std; 7 8 int main(){ 9 int T;10 cin>>T;11 for(int iCase = 1; iCase <= T; iCase ++){12 int N,M;13 cin>>N>>M;14 map<string,string& 阅读全文
posted @ 2013-04-06 18:55 OpenSoucre 阅读(327) 评论(2) 推荐(1) 编辑
摘要: 1002. Phone NumbersTime Limit: 2.0 secondMemory Limit: 64 MBIn the present world you frequently meet a lot of call numbers and they are going to be longer and longer. You need to remember such a kind of numbers. One method to do it in an easy way is to assign letters to digits as shown in the follow 阅读全文
posted @ 2013-04-06 00:00 OpenSoucre 阅读(313) 评论(0) 推荐(0) 编辑
摘要: 1001. Reverse RootTime Limit: 2.0 secondMemory Limit: 64 MBThe problem is so easy, that the authors were lazy to write a statement for it!InputThe input stream contains aset ofinteger numbersAi(0≤Ai≤ 1018). The numbers are separated byany number ofspaces and line breaks. Asize ofthe input stream doe 阅读全文
posted @ 2013-04-05 19:32 OpenSoucre 阅读(368) 评论(0) 推荐(0) 编辑
上一页 1 ··· 9 10 11 12 13