摘要: Bound_Ptr.h 1 // -*- C++ -*- 2 3 //============================================================================= 4 /** 5 * @file Bound_Ptr.... 阅读全文
posted @ 2015-06-03 23:37 YipWingTim 阅读(303) 评论(0) 推荐(0) 编辑
摘要: 1 #include "buddy.h" 2 #include 3 #include 4 #include 5 #include 6 #include 7 8 #define NODE_UNUSED 0 9 #define NODE_USED 1 10 #de... 阅读全文
posted @ 2015-03-30 23:07 YipWingTim 阅读(235) 评论(0) 推荐(0) 编辑
摘要: 子数组和//Algorithm 1:时间效率为O(n*n*n) int MaxSubsequenceSum1(const int A[],int N) { int ThisSum=0 ,MaxSum=0,i,j,k; for(i=0;iMaxSum) MaxSum=ThisSum; } return MaxSum; } //Algorithm 2:时间效率为O(n*n) int MaxSubsequenceSum2(const int A[],int N) { int Thi... 阅读全文
posted @ 2013-10-02 13:47 YipWingTim 阅读(204) 评论(0) 推荐(0) 编辑
摘要: public string returnResult(long num){ string numStr=num.ToString(); if(numStr.Length>8 && numStr.Length4) { string[] split=new string[2]; split[0]=str.Substring(0,str.Length-4); split[1]=str.Substring(str.length-4,4); string result1=getRe(split[0]); string... 阅读全文
posted @ 2013-10-02 13:44 YipWingTim 阅读(365) 评论(0) 推荐(0) 编辑
摘要: 思路要清晰。View Code 1 //两队列实现栈 2 #include<iostream> 3 using namespace std; 4 5 template<class Type> class Queue 6 { 7 private: 8 int rear,front; 9 Type* elements; 10 int maxSize; 11 public: 12 Queue(int sz=50):rear(0),front(0),maxSize(sz) 13 { 14 elements=new Type[... 阅读全文
posted @ 2011-11-16 05:04 YipWingTim 阅读(293) 评论(0) 推荐(0) 编辑
摘要: 比较简单。View Code 1 //用两个栈实现队列 2 3 #include<iostream> 4 using namespace std; 5 6 template<class Type> class Stack 7 { 8 private: 9 int top;10 Type* elements;11 int maxSize;12 public:13 Stack(int sz=50):top(-1),maxSize(sz)14 {15 elements=new Type[sz];16 }17 18 void... 阅读全文
posted @ 2011-11-16 03:19 YipWingTim 阅读(206) 评论(0) 推荐(1) 编辑
摘要: 猴子分桃海滩上有一堆桃子,五只猴子来分。第一只猴子把这堆桃子平均分为五份,多了一个,这只猴子把多的一个扔入海中,拿走了一份。第二只猴子把剩下的桃子又平均分成五份,又多了一个,它同样把多的一个扔入海中,拿走了一份,第三、第四、第五只猴子都是这样做的,问海滩上原来最少有多少个桃子?View Code 1 #include<iostream> 2 using namespace std; 3 4 int main() 5 { 6 int m=1; 7 while(1) 8 { 9 int n=m;10 int i;11 fo... 阅读全文
posted @ 2011-11-16 02:22 YipWingTim 阅读(218) 评论(0) 推荐(0) 编辑
摘要: 代码比较简单,测试都懒得了,这个问题思想是精华。View Code 1 #include<iostream> 2 using namespace std; 3 4 class Stack 5 { 6 private: 7 int *elements; 8 int top; 9 int maxSize; 10 11 public: 12 Stack(int sz=50):top(-1),maxSize(sz) 13 { 14 elements=new int[maxSize]; 15 } 16 17 ... 阅读全文
posted @ 2011-11-15 19:25 YipWingTim 阅读(346) 评论(0) 推荐(0) 编辑
摘要: 哈哈。只考虑了两个小时左右,我已经深的递归精髓了,哈哈。递归解决问题真的是太容易了,归纳演绎完全诠释了数学的精妙,哈,这个世界好得很。。。。重复感叹一句,迭代的是人,递归的是神。。。。分析时间复杂度,公式为f(n)=2*f(n-1)+f(n-2),可以用递归求出通项,初略估计为3^n。View Code 1 #include<iostream> 2 using namespace std; 3 4 class Stack 5 { 6 private: 7 int* elements; 8 int top; 9 int maxSize;10 public:11 ... 阅读全文
posted @ 2011-11-15 02:10 YipWingTim 阅读(911) 评论(0) 推荐(0) 编辑
摘要: View Code 1 #include<iostream> 2 #include<assert.h> 3 using namespace std; 4 5 //const int maxSize=50; 6 const int stackIncreament=20; 7 8 9 10 template<class T> class Stack 11 { 12 public: 13 Stack(){}; //由于没写{},一直报错。undefined reference to Stack<int>::stack 注意模板的分离编译。 14 vir 阅读全文
posted @ 2011-11-14 02:27 YipWingTim 阅读(502) 评论(0) 推荐(0) 编辑