原创 簡單棧應用-表達式求值

#include<iostream> #include<string> #include<stack> using namespace std; const int MAX_SIZE = 100; //棧 stack<int>O

原创 //統計數字問題

//統計數字問題 /* 統計全部頁碼分別用了多少0~9 */ #include<iostream> using namespace std; int a[9]={0};//初始化爲0 void Solution() {

原创 解密QQ

/*解密QQ號:首先將第 1個數刪除,緊接着將第 2個數放到 這串數的末尾,再將第 3個數刪除並將第 4個數放到這串數的末尾,再將第 5個數刪除…… 直到剩下後一個數,將後一個數也刪除。按照剛纔刪除 的順序,把這些刪除的數連在一

原创 螞蟻

//螞蟻, /*n只螞蟻以1cm的速度在一個長爲Lcm的杆子上爬行,當螞蟻爬行到杆子的端點處就會掉下去 同時螞蟻的方向不確定,當兩隻螞蟻碰到一起,將會向相反的方向爬去,詢問最長時間及最短時間 (注意所有螞蟻都在爬行,只用注意一隻螞

原创 迷宮

//走迷宮隊列 #include<iostream> using namespace std; #define M 5 #define N 4 //迷宮 typedef struct mg { int x,y;//每個

原创 //最大乘積

//最大乘積 #include<iostream> using namespace std; const int maxn = 100; int A[maxn]; int sum;//存儲最大積 #define INF 1e10

原创 簡單枚舉-除法

//簡單枚舉-除法,輸入正整數n,按從小到大的順序輸出所有形如abcde/fghij=n的表達式 #include<iostream> #include<algorithm> using namespace std; //0~9

原创 棧括號的處理

//棧括號 #include<iostream> #include<string> using namespace std; const int MAX_SIZE= 100;//定義棧的最大容量 //棧 typedef str

原创 部分和問題,深度優先搜索

//部分和問題,給定正整數a1,a2,a3...,判斷是否可以從中挑幾個數使其和爲k #include<iostream> using namespace std; #define MAXN 100 int a[MAXN]; i

原创 計算波蘭表達式

//計算波蘭表達式 #include<iostream> #include<string> using namespace std; const int MAX_SIZE = 100;//定義棧的最大容量 typedef st

原创 找尋路徑從根root到節點p的路徑函數

//從根root到節點p的路徑函數 void Path(btree *root,btree *p) { btree *stack[MAX_SIZE],*b; int tag[MAX_SIZE];//標記左右孩子

原创 //鏈表的原地逆轉

//鏈表的原地逆轉 #include<iostream> using namespace std; //結點 typedef struct node { int data; node *next; }node;

原创 鏈表逆轉

//鏈表的逆轉 //鏈表結點 typedef struct node { int data; node *next; }; void invert(node *head) { node *p,

原创 從鏈表A中刪除從i開始的len個元素,同時粘貼到B鏈表的第j元素之前

//從鏈表A中刪除從i開始的len個元素,同時粘貼到B鏈表的第j元素之前 #include<iostream> using namespace std; //結點 typedef struct node { int d

原创 //使用順序表實現循環隊列的入隊和出隊

//使用順序表實現循環隊列的入隊和出隊 #include<iostream> using namespace std; const int MAX_SIZE = 100; typedef struct Queue {