原创 客戶服務器編程示例

先建立兩個工程Server和Client,添加StdAfx.h和WINSOCK2.h兩個頭文件,然後編寫下面的兩段代碼: Server.cpp: #include "StdAfx.h" #include "WINSOCK2.h" #

原创 有一個集合A,它又n個元素,請用回溯法輸出它所有的子集。

#include<iostream> #define N 1000 using namespace std; int n,a[N],subset[N]; void print(){ for(int i=0;i<n;i++)

原创 恢復視力方法

1、遠方凝視: 找一處10米以外的草地或綠樹:綠色由於波長較短,成像在視網膜之前,促使眼部調節放鬆、眼睫狀肌鬆弛,減輕眼疲勞。不要眯眼,也不要總眨眼,排除雜念、集中精力、全神貫注的凝視25秒,辨認草葉或樹葉的輪廓。接着把左手掌略高於眼睛前

原创 1-SRM 144 DIV1

Problem Statement      Let's say you have a binary string such as the following: 011100011 One way to encrypt thi

原创 求高效算法

請用回溯法解決騎士巡遊問題(騎士巡遊問題是指:在8*8的國家象棋棋盤上,一匹馬從任意位置出發,按照象棋的規則走,要求踏遍整個棋盤,並且每個格子只能經過一次)。 #include<iostream> #include<cstring> #d

原创 TopCoder SRM558 backup 1 DIV 2

Problem Statement   Surrounding Game is a single-player game played on a rectangular grid of cells. Cells are consi

原创 棋盤覆蓋問題

Source Code:   #include<iostream> #include<cstdio> #include<cstring> using namespace std;   const int N=1024;   int boa

原创 下載ant,hadoop,lucene,nutch...的看過來

經常發現自己跑到Apache官網上找東西,今天偶然發現Apache有個鏈接地址包含了這些常用軟件,把地址貼在下面: http://archive.apache.org/dist/ 這個鏈接下面包含很多好東西,可以常來看看哦。

原创 最大子段和問題

int f(int a[],int n) { int ans,i; sum[0]=a[0]; ans=sum[0]; for(i=1;i<n;i++) { if(0<sum[i-1]) sum[i]=sum[i-1]+

原创 遍歷二叉樹

typedef struct BiTNode { TElemType data; struct BiTNode *lchild,*rchild; }BiTNode,*BiTree; void CreateBiTree(B

原创 數的全排列

#include<iostream> #include<cstring> #define N 4 using namespace std; int rec[N]; bool used[N]; int count=0; void Pr

原创 LIBXML學習(1)--添加元素

libxml2是一個c語言環境下生成和解析XML的一個工具,在Linux下安裝後,需要在編譯是指明庫/lib/local/include/libxml2,連接時添加參數-lxml2 -ldl -lm -lc。 在Linux的集成環境Ecl

原创 TSP問題之動態規劃解法

這幾天在想辦法求解TSP問題,衆所周知,TSP問題是NP難問題,現在我們用動態規劃來求解之。   其實這個可以轉化爲一個填表問題。 其中一步是求解集合的所有子集合,整個問題還沒完,等我哪天有時間了,把他詳細寫出來。 把求子集合的代碼先貼在

原创 OpenGL實例程序

#include<GL/glut.h> //#include<stdlib> void init(void) {//初始化材質屬性、光源屬性和光照模型 GLfloat mat_specular[]={1.0,1.0,0.0,1.0};

原创 0/1揹包問題

Charm Bracelet Description Bessie has gone to the mall's jewelry store and spies a charm bracelet. Of course, she'd l