第一家:你打多少?
我:一张A4
第一家:太少了,不打。
第二家:没有
第三家:你有纸么?
我:没
第三家:我帮你找找(纸)
翻了一圈后,第三家:对不起,没找到
柯达打印:好点的纸行不,照片的贴纸。
我:可以
打印。。。OK



Ubuntu 主力发行版,基于Gnome桌面环境
Kubuntu 基于KDE桌面环境
Xubuntu 基于Xface桌面环境
Edubuntu 用于教育目的的发行版
Hiweed 中文环境至上
Ubuntu CE 基督教徒专用
Ubuntu ME 回教徒专用
Ubuntu SE 魔鬼用ubuntu
Impi Linux 针对非洲的ubuntu
Linuxmint Ubuntu盗版
#include <iostream>
#include <algorithm>
using namespace std;
#define initSet(n,Arr) for(int i=0;i<n;++i)Arr[i]=i;
#define MAX 1<<30;
int graph[600][600];
// Stoer-Wagner Algorithm
int globalMinCut(int n){
// A is A set for Stoer-Wagner Algorithm
bool* A=new bool[n];
// V is vertex index
int* V=new int[n];
int* W=new int[n];
initSet(n,V);
int best=MAX;
while(n>1){
//the most tightly connected vertex.
int maxj=1;
// initialize set A and other vertex's weight
A[V[0]] = true;
for(int i=1; i<n; ++i){
A[V[i]]=false;
W[i]=graph[V[0]][V[i]];
if(W[i]>W[maxj])
maxj=i;
}
// find a min-cut
int prev=0,buf=n;
while(--buf){
// add it to A
A[V[maxj]]=true;
if(buf==1){
// update min cut
best=min(best,W[maxj]);
// merge prev and last vertex
for(int k=0; k<n; ++k)
graph[V[k]][V[prev]]=(graph[V[prev]][V[k]]
+=graph[V[maxj]][V[k]]);
V[maxj]=V[--n];
}
prev=maxj;
maxj=-1;
// update the weights
for(int j=1; j<n; ++j)
if(!A[V[j]]){
W[j]+=graph[V[prev]][V[j]];
if(maxj<0 || W[j]>W[maxj])
maxj=j;
}
}
}
delete[] A;
delete[] V;
delete[] W;
return best;
}
int main(){
// n - vertex number
// m - edge number
int n,m;
while(scanf("%d %d",&n,&m)==2){
memset(graph,0,sizeof(graph)/sizeof(bool));
// v-w is an edge with c weight
int v,w,c;
while(m--){
scanf("%d %d %d",&v,&w,&c);
graph[v][w]+=c;
graph[w][v]+=c;
}
// output min cut
printf("%d\n",globalMinCut(n));
}
}

(假设满足求n个condition的记录数count=0)
if condition is empty
count=recordNum, exit
准备一个索引数组tb,tb[i]代表 i 条件下的当前记录号。tb初始全-2。
foreach condition as ci
int tmp= IndexTable中ci条件的startid值,无法满足ci,则tmp=-1
if tb[ci] 已存在,即 !=-2
if tb[ci]!= tmp
count=0, exit
else
next condition
else
tb[ci]=tmp
依某算法(算法很多,自定吧)取字段c为主键,可以理解为取某个condition为主条件
while tb[c]!=-1
foreach condition as ci
if ci==c
continue
else
while tb[ci]<tb[c] && tb[ci]>=0
tb[ci] = Table[tb[ci]][ci] // next record
if tb[ci]>tb[c] || tb[ci]==-1
break;
if all condition matched
count++
else
tb[c]=Table[tb[c]][c]
count is result
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <utility>
#include <sstream>
#include <algorithm>
using namespace std;
// DB structs
// first is startId, second is len(len may be tempory used for other target)
typedef pair<int,int> Index;
typedef map<string,Index> FieldIndex;
typedef vector<FieldIndex> IndexTable;
typedef map<string,int> ColumnName;
typedef vector<int> Record;
struct DB{
// a table (since only one table provided)
string name;
vector<Record> records;
int recordNum,columnNum;
ColumnName nameMap;
IndexTable it;
DB(int n,int c):recordNum(n),columnNum(c){
records.resize(n);
it.resize(c);
for(int i=0;i<n;++i){
records[i].resize(c);
}
}
};
// Query structs
typedef pair<string,string> Expression;
typedef vector<Expression> Query;
// called while constructing the DB and IndexTable
int addValue(FieldIndex& index, string& value,int curIndex){
map<string,Index>::iterator iter=index.find(value);
int lastIndex=-1;
if(iter==index.end()){
index[value]=Index(curIndex,curIndex);
}else{
lastIndex=index[value].second;
index[value].second=curIndex;
}
return lastIndex;
}
void initDB(DB& db){
string buf;
// parse db name
cin>>db.name;
getline(cin,buf);
// parse column name
getline(cin,buf);
stringstream ss(buf);
string name;
for(int i=0;i<db.columnNum;++i){
ss>>name;
db.nameMap[name]=i;
}
// parse db records
for(int i=0;i<db.recordNum;++i){
getline(cin,buf);
stringstream ss(buf);
for(int j=0;j<db.columnNum;++j){
string value;
ss>>value;
db.records[i][j]=-1;
int lastId=addValue(db.it[j],value,i);
if(lastId>=0){
db.records[lastId][j]=i;
}
}
}
}
bool isExpression(string& str){
int len=str.length();
for(int i=0;i<len;++i){
if(str[i]=='=')return true;
}
return false;
}
bool validChar(char c){
return (c>='0' && c<='9') || (c>='a' && c<='z') || (c>='A' && c<='Z');
}
void parseExpression(string& str, Expression& exp){
int i=0,st=0,len=0;
while(!validChar(str[i]))++i;
st=i;
while(validChar(str[i]))++i;
len=i-st;
exp.first=str.substr(st,len);
while(!validChar(str[i]))++i;
st=i;
while(validChar(str[i]))++i;
len=i-st;
exp.second=str.substr(st,len);
}
int doQuery(DB& db,string& q){
int cnt=0;
stringstream ss(q);
string buf;
Query query;
while(ss>>buf){
if(isExpression(buf)){
Expression exp;
parseExpression(buf,exp);
query.push_back(exp);
}
}
if(query.empty())return db.recordNum;
int* tb=new int[db.columnNum];
fill(tb,tb+db.columnNum,-2);
for(Query::iterator iter=query.begin(); iter!=query.end(); ++iter){
int col=db.nameMap[iter->first];
map<string,Index>::iterator mapIter=db.it[col].find(iter->second);
if(mapIter!=db.it[col].end()){
int st=(mapIter->second).first;
if(tb[col]>=0 && st!=tb[col]){
return 0;
}else if(tb[col]<0){
tb[col]=st;
}
}else tb[col]=-1;
}
int lastValue=-1;
while(true){
int i=0,curValue=-1;
for(;i<db.columnNum;++i){
if(tb[i]==-2)continue;
if(lastValue>=0 && tb[i]==lastValue){
tb[i]=db.records[tb[i]][i];
}
if(tb[i]==-1)break;
if(curValue==-1){
curValue=tb[i];
}else{
while(tb[i]<curValue && tb[i]>=0){
tb[i]=db.records[tb[i]][i];
}
if(tb[i]>curValue || tb[i]<0){
break;
}
}
}
lastValue=curValue;
if(tb[i]==-1 || curValue==-1)break;
if(i==db.columnNum){
++cnt;
}
}
delete[] tb;
return cnt;
}
// main entry
int main(){
int c,n,q;
cin>>c>>n>>q;
DB db(n,c);
initDB(db);
string line;
while(q--){
getline(cin,line);
cout<<doQuery(db,line)<<endl;
}
}
// method one, after counting
count[6]=count[9]=(count[6]+count[9]+1)/2; // forget add one will be chanllenged
// method two, in counting iteration
if(count[6]<count[9]) count[6]++;
else count[9]++;
public int calcMinimalCost(int[] arr){
int total=0,len=arr.length,maxCost=0;
int[] cost=new int[len];
for(int i=0;i<len;++i){
cost[i]=arr[i];
total+=arr[i];
for(int j=0;j<i;++j){
if(arr[j]<=arr[i] && cost[j]+arr[i]>cost[i]){
cost[i]=cost[j]+arr[i];
}
}
maxCost=Math.max(cost[i],maxCost);
}
return total-maxCost;
}

<connector port="8080"
maxthreads="150" minsparethreads="25" maxsparethreads="75"
enablelookups="false" redirectport="8443" acceptcount="100"
connectiontimeout="20000" disableuploadtimeout="true"
emptysessionpath="true" />
CREATE TABLE sometable (some_id INT(8) AUTO_INCREMENT, PRIMARY KEY(some_id));
CREATE TABLE sometable (some_id SERIAL, PRIMARY KEY(some_id));
CREATE TABLE sometable (some_id integer NOT NULL DEFAULT nextval('sometable_some_id::regclass')
, PRIMARY KEY(some_id));
CREATE TABLE average_temperature
(
year INTEGER,
temp REAL,
season TEXT (CHECK season IN ('spring', 'summer', 'autumn', 'winter'))
);
CREATE DOMAIN season_type
AS TEXT
CHECK (VALUE IN ('spring', 'summer', 'autumn', 'winter'));
CREATE TABLE average_temperature
(
year INTEGER,
temp REAL,
season season_type
);
CREATE TABLE season_lookup
(
code INT PRIMARY KEY,
value TEXT NOT NULL
);
INSERT INTO season_lookup VALUES(1,'spring');
INSERT INTO season_lookup VALUES(2,'summer');
INSERT INTO season_lookup VALUES(3,'autumn');
INSERT INTO season_lookup VALUES(4,'winter');
CREATE TABLE average_temperature
(
year INTEGER,
temp REAL,
season INT REFERENCES season_lookup(code)
);
int a=0;
const int *p1=&a; //指常量的指针,此处a可以是常量也可以不是,但结果是(*p1)不能再修改
int *const p2=&a; //常量指针,不可以改变p的指向,功能类似引用(但有区别)
const int *const p3=&a; //指常量的常量指针,上面两个特点综合一下
double a=0.0;
const int &b=a; //其实是先 int tmp=a;然后 const int &b=tmp; 因为b要引一个int对象,所以临时创建了一个
const int &c=0; //其实是先 int tmp=0;然后 const int &c=tmp; 同上,先创建一个对象
int *const &p=a; // 经检验,效果等同 int *const p=a;
// 数组习惯
vector<int> vct(10);
for(int i=0 ; i<vct.size() ; ++i)
vct[i]=i;
// STL 习惯
vector<int> vct;
for(int i=0 ; i<10; ++i)
vct.push_back(i);
for(vector<int>::iterator iter=vct.begin() ; iter!=vct.end() ; ++iter)
cout<< *iter << endl;
#include <iostream> //包含需要使用的头文件
class Sample; // 先声明一下类
// 声明一些会使用到该类的函数
istream& operator >( istream&, Sample&);
// 类定义
class Sample
{
public:
Sample(); //默认构造函数及其他构造函数
Sample( const Sample&); //拷贝构造函数,如果需要
~Sample(); //析构
Sample& operator = (const Sample&); //重载操作符
void setValue(int); //定义成员函数
private:
int _value; //定义成员变量
};
void putValues(int*);
void putValues(int[]);
void putValues(int[ 10 ]);
void putValues(int (&arr)[10]); //参数为10个int的数组,因为参数是引用的,即数组长度成为参数的一部分
void putValues(int matrix[][10], int rowSize); // 第一维长度为rowSize,第二维长度是10
void putValues( vector<int> &vec ); //vector是替代数组的最好类型
int func1(int a,int b=0,int c=0);
int func2(int a,int b,int c=0); // 初始化最右边参数
int func2(int a,int b=0,int c); //可以!此时b c都有缺省参数
int func2(int a,int b=0,int c=0); //错误,bc已经有缺省参数
int func3(int a,int b,int c=func1(1)); //缺省实参可以是任意表达式
int func4(...); // ellipsis 省略号,告知编译器,函数调用时,可以有0或多个实参,而类型未知
Matrix& func()
{
Matrix a;
return a; // 错误,结果将指向一个错误的位置
}
int& get_val( vector<int> &vi, int ix)
{
return vi[ix];
}
int ai[4] = {0,1,2,3};
vectorvec(ai, ai+4);
int main()
{
get_val(vec,0)++;
}
Matrix& get(Matrix *p)
{
Matrix *res = new Matrix(); //动态分配的,函数结束不会结束
*res=*p;
return *res;
}
int cmp1(const string &s1, const string &s2)
{
return 1;
}
int cmp2(const string &s1, const string &s2)
{
return 0;
}
int *pf(const string&, const string&amp;amp;amp;amp;amp;); // 错误,返回类型指针
int (*pv)(const string&, const string&amp;amp;amp;amp;amp;) = 0; //初始化,不指向任何东西
int (*pf)(const string&, const string&amp;amp;amp;amp;amp;) = cmp1; //正确,pf 是指向函数的指针
pf=cmp2; //赋值,可以
pf=&cmp1; //可以,同上
cmp1("a","b");
pf("a","b");
(*pf)("a","b"); //三个效果相同,返回1
int func1(const int &a,const int &amp;amp;amp;amp;amp;b);
int func2(const int &a,const int &amp;amp;amp;amp;amp;b);
typedef int (*PFV)(); //定义函数类型指针的typedef
PFV tc1[10]; // 函数指针数组长度为10
PFV tc2 = { func1, func2 }; // 初始化
tc1[0] = &func1; // 赋值
tc1[0](10,20); //调用
((*tc1)[0])(10,20); // 显式调用
int (*func(int))(int, int); // ff为函数,有一个int参数,返回一个指向函数的指针,该指针类型为 int (*)(int, int);
typedef int (*PF)(int, int);
PF ff( int ); //更优雅
typedef int func(int, int);
func ff(int); // 错误,返回类型不能是函数类型
extern "C" void exit(int);
extern "C"
{
int printf( const char* ...);
int scanf(const char* ...);
}
extern "C"
{
#include <cmath>
}
for( register int ix=0; ix
#include
auto_ptr< type_pointed_to > identifier( ptr_allocated_bynew );
auto_ptr< type_pointed_to > identifier( auto_ptr_of_same_type );
auto_ptr< type_pointed_to > identifier;
auto_ptr< int > pi(new int(1024));
new ( place_address ) type-specifier // 表达式格式
class Foo{};
char *buf = new char [ 1024 ];
Foo *pb = new ( buf ) Foo; //无须delete
delete[] buf;
Class.forName("org.postgresql.Driver");
Connection db = DriverManager.getConnection("jdbc:postgresql://localhost:5432/jetspeed", "jetspeed", "jetspeed");
$ initdb -D /usr/local/pgsql/data
$ postmaster -S -D /usr/local/pgsql/data #start the db server background
$ psql template0
listen_addresses='*'
port=5432
tcpip_socket=true
local all password
host all all 127.0.0.1/32 password
$ createuser -d -P # create a user with the privilege of database create and a prompt for the password of the new userd
... # input the user info,like username is 'jetspeed' and password is 'jetspeed'
$ createdb jetspeed -U jetspeed -W # create a new db and the creator is 'jetspeed'
# if error reported, maybe pg_hba.conf was incorrected configured.