摘要: 更新Android SDK Manager,提示连接不到 https://dl-ssl.google.com的解决办法!c:\windows\system32\drivers\etc复制到搜索窗口中,点击立即搜索,就找到hosts文件,其实是一个纯文本的文件。1、用记事本打开2、将74.125.237.1dl-ssl.google.com添加至最后一行3、保存关闭Host(前提是你有修改这个文件的权限)MAC 系统下:先打开终端输入sudo nano /etc/hosts,回车,输入系统登录密码,然后用键盘移动光标到相应位置增加ip,74.125.237.1dl-ssl.google.com 阅读全文
posted @ 2013-04-26 14:00 翛尧 阅读(795) 评论(0) 推荐(0)
摘要: #include <cstdlib>#include <iostream>using namespace std;template<typename T>class Heap//最大堆{private: int currentSize; int maxSize; T *heapArray; public: Heap(int size = 10) { currentSize = 0; maxSize = size; //初始化堆容量 heapArray = new T[maxSize]; //创建堆... 阅读全文
posted @ 2012-10-22 14:25 翛尧 阅读(308) 评论(0) 推荐(0)
摘要: 从给定的N个正数中选取若干个数之和最接近M阶段是:在前N件物品中,选取若干件物品放入背包中; 状态是:在前N件物品中,选取若干件物品放入所剩空间为W的背包中的所能获得的最大价值; 决策是:第N件物品放或者不放; 由此可以写出动态转移方程: 我们用f[i,j]表示在前 i 件物品中选择若干件放在所剩空间为 j 的背包里所能获得的最大价值 f[i,j]=max{f[i-1,j-Wi]+Pi (j>=Wi), f[i-1,j]} 这个方程非常重要,基本上所有跟背包相关的问题的方程都是由它衍生出来的。所以有必要将它详细解释一下:“将前i件物品放入容量为v的背包中”这个子问题,若只考虑... 阅读全文
posted @ 2012-10-22 10:49 翛尧 阅读(236) 评论(0) 推荐(0)
摘要: #include<iostream>#include<math.h>#define N 100000 //生成100000个质数using namespace std;int prime[N]; //一个全局数组,用来保存质数表void makeprime()//生成质数表的子函数{ int j,n=29,i=9,sqrtn;//从第10个质数开始计算,第10个质数是29 prime[0]=2; prime[1]=3; prime[2]=5; prime[3]=7; prime[4]=11; prime[5]=13; prime[6]=17; ... 阅读全文
posted @ 2012-10-16 21:53 翛尧 阅读(408) 评论(0) 推荐(0)
摘要: bool findString(char* str, char* t){ if('\0' == *t) return 1; if('*' == *t){while('\0' != *str){if(findString(str++, t + 1))return 1;}}if('\0' == *str)return 0;if('?' == *t || *str == *t){return findString(str + 1, t + 1);}return 0;} 阅读全文
posted @ 2012-09-28 23:05 翛尧 阅读(382) 评论(0) 推荐(0)
摘要: #include<iostream>#include<string>usingnamespacestd;stringadd(conststring&a,conststring&b){stringresult;//用于记录计算结果intlen_a=a.length()-1;intlen_b=b.length()-1;intcarry=0;//进位for(;len_a>=0&&len_b>=0;len_a--,len_b--){intt=(a[len_a]-'0')+(b[len_b]-'0')+c 阅读全文
posted @ 2012-09-21 23:17 翛尧 阅读(398) 评论(0) 推荐(0)
摘要: #include <cstdlib>#include <iostream>using namespace std;int Partition(int list[], int low, int high){ int pivotkey = list[low]; while(low < high) { while(low<high && list[high]>= pivotkey) high--; //找到第一个小于key的记录 if(low < high) list[low++] = list[high];//相当于交换了list[i 阅读全文
posted @ 2012-09-07 16:00 翛尧 阅读(112) 评论(0) 推荐(0)
摘要: #include <stdio.h>#include <stdlib.h>static char Queen[8][8];static int a[8];static int b[15];static int c[15];static int iQueenNum = 0;//record statevoid qu(int i);int main(int argc, char *argv[]){ //init int line, column; for(line = 0;line < 8;line++) { a[line] = 0; for(colu... 阅读全文
posted @ 2012-09-06 16:06 翛尧 阅读(131) 评论(0) 推荐(0)
摘要: 使用异或a = a^b;b = a^b;a = a^b;异或运算法则 1. a ^ b = b ^ a 2. a ^ b ^ c = a ^ (b ^ c) = (a ^ b) ^ c; 3. d = a ^ b ^ c 可以推出 a = d ^ b ^ c. 4. a ^ b ^ a = b. 阅读全文
posted @ 2012-09-05 16:31 翛尧 阅读(228) 评论(0) 推荐(0)
摘要: int max = ((a+b) + abs(a-b)) / 2; 阅读全文
posted @ 2012-09-05 16:26 翛尧 阅读(180) 评论(0) 推荐(0)