- 博客(36)
- 收藏
- 关注
原创 11-散列4 Hashing - Hard Version
//这个代码并不能完美通过,只能得26分,有一个测试点过不了//总之我还没调试出来,如果有人看见了能指出问题欢迎评论留言#include #include #define Max 1000#define MinData -100000001int Graph[Max][Max];typedef struct HeapStruct *MinHeap;struct HeapStru
2015-10-03 16:39:13
968
1
原创 11-散列3 QQ帐户的申请与登陆
#include #include #include typedef struct ListNode *Position;typedef struct ListNode{ char account[11], password[17]; Position Next;} *List;typedef struct HashTbl{ int TableSize; List *The
2015-10-03 16:38:28
1432
原创 11-散列2 Hashing
#include #include typedef struct HashTbl{ int TableSize; int *Elements; int *Staus;} *HashTable;int NextPrime(int x);HashTable InitializeTable(int TableSize);void DestroyTable(HashTable H);
2015-10-03 16:37:33
913
原创 11-散列1 电话聊天狂人
#include #include #include typedef struct ListNode *Position;typedef struct ListNode{ char PhoneNum[12]; int cnt; Position Next;} *List;typedef struct HashTbl{ int TableSize; List *TheLis
2015-10-03 16:36:41
1751
原创 10-排序6 Sort with Swap(0, i)
#include void swap(int *a, int *b){ int tmp = *a; *a = *b; *b = tmp;}// int findNotOk(int A[], int N)int findNotOk(int A[], int begin, int N)// 要从begin开始,从1开始会超时{ for (int i = begin; i < N;
2015-10-02 17:03:39
1350
原创 10-排序5 PAT Judge
#include #include typedef struct stu{ int id; int s[6];//各题分数 int score;//总分 int pass;//完全正确的题目数 int ns;//无提交或无任何通过编译标志,0代表没有通过} Stu;void sort(Stu stu[], int N);int compare(const Stu *s1,
2015-10-02 15:04:30
695
原创 10-排序4 统计工龄
#include #define Bucket_Nums 51void Bucket_Sort(int A[], int N);int main(int argc, char const *argv[]){ // freopen("test.txt", "r", stdin); int N; scanf("%d", &N); int A[N], tmp; for (int
2015-10-02 11:10:31
1231
原创 09-排序3 Insertion or Heap Sort
#include #include void Insertion_Sort(int A[], int N);void PercDown(int A[], int i, int N);int compare(int a[], int b[], int N){ for (int i = 0; i < N; i++){ if (a[i] != b[i]) return 0;
2015-10-02 10:35:42
520
原创 09-排序2 Insert or Merge
#include #include void Insertion_Sort(int A[], int N);void Merge_pass(int A[], int tmpA[], int N, int length);void Merge(int A[], int tmpA[], int L, int R, int RightEnd);int compare(int a[], in
2015-10-02 10:34:59
756
原创 09-排序1 排序
#include #include void Bubble_Sort(long long int A[], int N);void Insertion_Sort(long long int A[], int N);void Shell_Sort(long long int A[], int N);void Heap_Sort(long long int A[], int N);
2015-10-02 10:34:02
584
原创 08-图9 关键活动
#include #define MAXINT 0x7fffffff#define Max 101int Graph[Max][Max], Indegree[Max], Outdegree[Max], Earliest[Max], Latest[Max];int max(int a, int b){ if (a > b) return a; else return b;
2015-10-02 10:33:08
1005
原创 08-图8 How Long Does It Take
#include #define Max 100int Graph[Max][Max], Indegree[Max], Outdegree[Max], Earliest[Max];int max(int a, int b){ if (a > b) return a; else return b; }int Earliest_Time(int N);int main
2015-10-02 10:32:21
864
原创 08-图7 公路村村通
#include #define MAXINT 0x7fffffff#define Max 1001int Graph[Max][Max];int Prim(int N);void DFS(int N, int i, int *Visited);int main(int argc, char const *argv[]){ // freopen("test.txt", "r"
2015-10-02 10:31:30
1516
原创 07-图6 旅游规划
#include #define Max 505int Graph[Max][Max], Cost[Max][Max];void Dijkstra(int S, int N, int *dist, int *cost);int main(int argc, char const *argv[]){// freopen("test.txt", "r", stdin); int N
2015-10-02 10:30:35
669
原创 07-图5 Saving James Bond - Hard Version
#include #include typedef struct { int x, y; int pre; int escape;} Vertex;typedef struct Node { int value; struct Node *next;} Table;int Abs(int a) //求a的绝对值{ if (a < 0) a = -a; retu
2015-10-02 10:29:40
593
原创 07-图4 哈利·波特的考试
#include int Min(int a, int b);int Max(int a, int b);int main(int argc, char const *argv[]){ // freopen("test.txt", "r", stdin); int N, M; scanf("%d %d", &N, &M); int graph[N+1][N+1]; for (
2015-10-02 10:28:28
1898
原创 06-图3 六度空间
有借鉴http://blog.csdn.net/xkzju2010/article/details/46503251#include #include #define MaxVertexNum 10000int *Visited;typedef struct QNode{ int Data[MaxVertexNum]; int rear; int front;} QNode,
2015-09-27 16:37:49
991
原创 06-图2 Saving James Bond - Easy Version
#include #include #define Island_Diameter 15int Visited[105];int FirstJump(int *a, int i, int D);int IsSafe(int *a, int i, int D);int Jump(int *a, int i, int j, int D);int DFS(int *a, int i,
2015-09-27 16:36:41
508
原创 06-图1 列出连通集
#include #include #define MaxVertexNum 10int Visited[MaxVertexNum];typedef struct MGraph{ int Vertices[MaxVertexNum]; int Edges[MaxVertexNum][MaxVertexNum]; int n, e;} MGraph;typedef struc
2015-09-27 16:35:48
1945
原创 05-树9 Huffman Codes
#include #include #define MinData 0typedef struct TreeNode* HuffmanTree;struct TreeNode{ int weight; HuffmanTree Left; HuffmanTree Right;};typedef struct HeapStruct *MinHeap;struct HeapS
2015-09-27 16:34:46
1140
原创 05-树8 File Transfer
#include #include int Find(int x, int s[]);void Union(int c1, int c2, int s[]);int main(int argc, char const *argv[]){ int *s; int N, c1, c2; char ch; scanf("%d", &N); s = (int*)malloc(siz
2015-09-27 16:33:56
1130
1
原创 05-树7 堆中的路径
#include #include #define MinData -10001typedef struct HeapStruct *MinHeap;struct HeapStruct{ int *elements; int size; int capacity;};MinHeap Creats(int MaxSize);void Min_Insert(MinHeap H
2015-09-27 16:33:07
564
原创 04-树6 Complete Binary Search Tree
#include #include int compare(const void *a, const void *b);void Solve(int ALeft, int ARight, int TRoot, int A[], int T[]);int Get_Left_Nodes(int n);int Min(int a, int b);int main(int argc, ch
2015-09-27 16:31:32
439
原创 04-树5 Root of AVL Tree
#include #include typedef int ElementType;typedef struct AVLNode *AVLTree; /* AVL树类型 */typedef struct AVLNode{ ElementType Data; /* 结点数据 */ AVLTree Left; /* 指向左子树 */ AVLTree Righ
2015-09-23 23:14:05
571
原创 04-树4 是否同一棵二叉搜索树
#include #include typedef struct TreeNode{ int data; struct TreeNode* Left; struct TreeNode* Right; int flag;}TreeNode, *Tree;Tree MakeTree(int N);Tree NewTreeNode(int tmp);Tree Insert(T
2015-09-23 23:12:12
2265
原创 03-树3 Tree Traversals Again
#include #include #include #define MAXSIZE 30typedef struct node{ int top; int cap; int data[MAXSIZE];} Stack;int preOrder[MAXSIZE];int inOrder[MAXSIZE];int postOrder[MAXSIZE];Stack* C
2015-09-22 17:18:14
762
原创 03-树2 List Leaves
#include #include #define MaxTree 10typedef struct TreeNode{ int number; int left; int right;} BinTree;BinTree T[MaxTree];typedef struct QNode{ int Data[MaxTree]; int rear; int front;}
2015-09-22 17:17:40
488
原创 03-树1 树的同构
#include #define MaxTree 10typedef struct TreeNode{ char element; int left; int right;} BinTree;BinTree BT1[MaxTree], BT2[MaxTree];int BuildTree(BinTree T[]);int Isomorphic(int root1, int
2015-09-22 17:16:35
726
原创 02-线性结构3 Pop Sequence
#include #include #define MaxSize 1001typedef struct node{ int top; int cap; int data[MaxSize];} Stack;Stack* CreateStack();void Push(Stack *PtrS, int e);void Pop(Stack *PtrS);int CheckS
2015-09-22 17:15:00
513
原创 02-线性结构2 Reversing Linked List
#include #define MAX_SIZE 100001typedef struct node{ int address; int data; int next_address; struct node * next;} Node; Node * ListReverse(Node * L, int k);void PrintList(Node * L);
2015-09-22 17:13:01
1105
原创 02-线性结构1 一元多项式的乘法与加法运算
#include #include typedef struct node{ int coefficient; int exponent; struct node * next;} PolyNode, *Polynomial;Polynomial ReadPoly();void Attach(int c, int e, Polynomial * Rear);Polynomi
2015-09-17 15:00:07
5319
原创 01-复杂度2 Maximum Subsequence Sum
#include int MaxSubseqSum(const int A[], int* p, int* q, int N){ int ThisSum = 0, MaxSum = 0; for (int i = 0; i < N; i++){ ThisSum += A[i]; if (ThisSum > MaxSum) MaxSum = ThisSum; el
2015-09-17 14:58:38
535
原创 01-复杂度1 最大子列和问题
#include int MaxSubseqSum(const int A[], int N){int ThisSum = 0, MaxSum = 0;for (int i = 0; i ThisSum += A[i];if (ThisSum > MaxSum)MaxSum = ThisSum;else if(ThisSum ThisSum = 0;}
2015-09-17 14:55:27
431
原创 PAT (Basic Level) Practise 1002
#include #include int main(int argc, char const *argv[]){char num[101] = {0};char *res[3]; char *pinyin[10] = {"ling","yi","er","san","si","wu","liu","qi","ba","jiu"};int sum = 0, cn
2015-04-18 10:31:40
397
原创 PAT (Basic Level) Practise 1001
#include int main(int argc, char const *argv[]){int n;int cnt = 0;scanf("%d", &n);while(n!=1){if(n%2==0){n/=2;cnt++;}else{n=(3*n+1)/2;cnt++;}}printf("%d", cnt);re
2015-04-18 10:30:26
409
原创 05-3. 求a的连续和(15)
#include #define MAXN 10int b[MAXN];int main(){ int sum, a, n; scanf("%d %d", &a, &n); b[0] = a; sum = a; if(n>1) { for( int i=1; i {
2015-03-28 14:25:59
384
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人