今天看了一些關於遞迴的知識,順便學習了一些經典的問題,敲了一些小**
首先是遞迴實現的經典的二分問題,**如下
#include #include using namespace std;
int a[10] = ;
int binsearch(int left, int right, int goal)
int main()
return 0;
}
接下來是經典的n皇后問題
這是自己寫的**
#include #include using namespace std;
int cnt = 0;
int x;
int safe(int row, int col,int xx[10])
}for(i=row, j=col; i=0; i++, j--)
}for(i=row, j = col ;i>=0 && j>x && x){
cnt = 0;
for(int i=0;i
#include #include using namespace std;
int cnt = 0;
int x;
int queen[10];
int isvalid(int i){
for(int j=0;j>x && x){
cnt =0;
queen(0);
cout<
遞迴的一些應用
遞迴 簡單來說就是自己呼叫自己。下面用乙個簡單的例子說明遞迴的主要步驟 include void up and down int intmain void void up and down int n printf level d n location p n n,n level 1 n locat...
一些經典的SQL
表結構 部門deptid,父級部門parentdeptid,資料庫的每一條記錄都記錄了自身id和父級部門id,現在要從某個部門查詢其下屬部門生成一棵部門關係樹,sql如下 select so.orgid,so.parentdeptid,so.orgname from sys orginfo so s...
Html 一些經典
標籤用於蒐集使用者資訊。根據不同的 type 屬性值,輸入字段擁有很多種形式。可以是文字字段 核取方塊 掩碼後的文字控制項 單選按鈕 按鈕等等。text 文字區域 readonly屬性 是否唯讀。password 密碼區域,輸入的文字以 展示 checkbox 核取方塊 checked屬性 是否選中...