随笔分类 -  C++算法设计

摘要:#ifndef __MyConsole__Stack__#define __MyConsole__Stack__#include templateclass Stack{public: explicit Stack(int size); ~Stack(); bool IsEmpty(); int CurrentSize(); bool Push(const T& item); bool IsFull(); void ShowStack(); bool Pop(T *pResult);private: int top; int maxSize; T *data; };us... 阅读全文
posted @ 2014-02-25 15:46 Predator 阅读(454) 评论(0) 推荐(0)
摘要:void SelectSort(int datas[], int len){ int tem; for (int i = 0; i datas[j]) { tem = datas[i]; datas[i] = datas[j]; datas[j] = tem; } } } for (int k = 0; k < len; ++k) { std::cout << datas[k] << " " ; } cout << endl;} 阅读全文
posted @ 2014-02-25 15:45 Predator 阅读(104) 评论(0) 推荐(0)
摘要:void BubbleSort(int datas[], int len){ int tem; bool isSorted = false; for (int i = len - 1; isSorted == false && i >= 1; --i) { isSorted = true; for (int j = 0; j datas[j + 1]) { isSorted = false; tem = datas[j]; datas[j] = datas[j + 1]; datas[j + 1] = tem; ... 阅读全文
posted @ 2014-02-25 15:45 Predator 阅读(121) 评论(0) 推荐(0)
摘要:#include using namespace std;int GetPeach(int nDay){if(nDay == 11){return 1;}return (GetPeach(nDay + 1) + 1) * 2;}void main(){int nTotal = 0;nTotal = GetPeach(1);cout > wait;} 阅读全文
posted @ 2013-09-14 11:06 Predator 阅读(506) 评论(0) 推荐(0)
摘要:int main(){int datas[10] = {-1, 2, 3, 4, 5, 6, 7 ,8, 9, 10};int max = 0;int min = 0; for(int i = 0; i datas[i]){min = datas[i];}}}cout > wait; return 0;} 阅读全文
posted @ 2013-08-29 10:37 Predator 阅读(3771) 评论(0) 推荐(0)
摘要:int datas[10] = {1, 2, 3, 4, 5, 6, 7 ,8, 9, 10};int *result = find(datas, datas + 10, 2);if(result == datas + 10){cout << "没有找到" << endl;}else{cout << "已经找到" << endl;}//输出已经找到 阅读全文
posted @ 2013-08-29 08:52 Predator 阅读(243) 评论(0) 推荐(0)
摘要:#include "hptime.h"#include #include #include #include using namespace std;void CalcTime(){unsigned long diff = 10000000;while(diff > 0){--diff;}Sleep(1000);}int main(){clock_t start, end;start = clock();CalcTime();end = clock();int tm =difftime(end, start);cout > wait; return 0;} 阅读全文
posted @ 2013-08-28 21:43 Predator 阅读(187) 评论(0) 推荐(0)
摘要:#include#include"common.h"#include#include#include"Calendar.h"#include#include#include#includeusingnamespaceboost::posix_time;usingnamespaceboost::gregorian;usingnamespacestd; typedefstructtagPerson{ stringname; intage;}Person; intmain(intargc){ stringname="zhangdong"; 阅读全文
posted @ 2013-07-20 14:55 Predator 阅读(1055) 评论(0) 推荐(0)
摘要:#include#include"common.h"#include#include#include"Calendar.h"#include#include#includeusingnamespaceboost::posix_time;usingnamespaceboost::gregorian;usingnamespacestd; structtagPerson{ stringname; intage;}Person; //去除左边的空格字符voidlTrim(char*str);//去除右边的空格字符voidrTrim(char*str);//去除左 阅读全文
posted @ 2013-07-20 14:39 Predator 阅读(547) 评论(0) 推荐(0)
摘要:#include #include using namespace std;//标准命名空间#define ARY_SIZE 10int main(){ bitsetb; for (int i = 0; i > wait; return 0;} 阅读全文
posted @ 2013-07-20 13:26 Predator 阅读(213) 评论(0) 推荐(0)
摘要:#include#includeusing namespace std;using namespace boost::gregorian;using namespace boost;//2013/07/01 09:24:30void main(){ //date myDate ; //myDate = from_undelimited_string("20130715131225"); //cout > wait;} 阅读全文
posted @ 2013-07-20 13:25 Predator 阅读(2066) 评论(0) 推荐(0)
摘要:#include //标准输入输出流#include "Utils.h"#include "Config.h"#include "stdio.h"#include "cloneable.h"#include "IPerfomanceEvalShare.h"#include using namespace xml_my_api;using namespace xml_api;using namespace std;//标准命名空间#define ARY_SIZE 10class CPork{pub 阅读全文
posted @ 2013-07-20 13:22 Predator 阅读(195) 评论(0) 推荐(0)
摘要:配置文件信息如下: 源代码:/************************************************************************版权声明(c)2010-2013,MronginfoLtd.所有权利保留.**本文件属于MronginfoLtd产品的一部分,版权归MronginfoLtd所有,*包括但不限于代码、注释及设计文档、会议记录等等。**本文件未经授权不得用于任何其它用途。*作者:甘全福 *创建日期:2013-7-12***************************************************... 阅读全文
posted @ 2013-07-13 13:11 Predator 阅读(1075) 评论(0) 推荐(0)
摘要:#include//标准输入输出流usingnamespacestd;//标准命名空间 constintCMP_LES=-1;//定义的常量constintCMP_EQU=0;constintCMP_BIG=1; classComparer//仿函数的类函数的主要功能是重载运算符()这样调用的时候就直接用类引用加上()后面的参数就可以{public: Comparer(intcmpType) { m_cmpType=cmpType;//初始化变量 } booloperator()(intnum1,intnum2)const { boolres; switch(m_cmpType) {... 阅读全文
posted @ 2013-07-09 21:25 Predator 阅读(365) 评论(0) 推荐(0)
摘要:// mysqlTest.cpp : 定义控制台应用程序的入口点。//#include "stdafx.h"#include #include #include #include #include #include using namespace std;class Person{public: Person(string name){this->m_name = name;} void Display(){cout Display();}int _tmain(int argc, _TCHAR* argv[]){ Test test; test.DisplayIn() 阅读全文
posted @ 2013-07-09 19:54 Predator 阅读(884) 评论(0) 推荐(0)
摘要:// mysqlTest.cpp : 定义控制台应用程序的入口点。//#include "stdafx.h"#include #include #include #include using namespace std;int _tmain(int argc, _TCHAR* argv[]){ CMRDBIO myDb(DBTYPE::DB_MYSQL);// string strSQL ; //strSQL = "insert into person values('dfsdf', 24) "; //cout GetRecordCoun 阅读全文
posted @ 2013-07-09 19:51 Predator 阅读(401) 评论(0) 推荐(0)
摘要:#pragma once#include "persistable.h"#include "memento.h"#include#include using namespace std;class CFGStudent:public xml_api::Persistable{public: CFGStudent(void); ~CFGStudent(void);public: virtual bool SaveState(xml_api::Memento* m); // 读取配置 virtual bool LoadState(xml_api::Memen 阅读全文
posted @ 2013-07-09 19:48 Predator 阅读(2298) 评论(0) 推荐(0)
摘要:#include "stdafx.h"#include "FGConfig.h"#include "Utils.h"#include "persistable.h"#include #include using namespace std;using namespace xml_api;#include inline void EnableMemLeakCheck(){ _CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_D 阅读全文
posted @ 2013-07-09 19:47 Predator 阅读(294) 评论(0) 推荐(0)
摘要:deque deq; for (int i = 0; i < 20; ++i) { deq.push_back(i); } for (int j = 0; j < 20; ++j) { int tem = deq.back(); cout << tem << " " ; deq.pop_back(); //cout << deq[j] << " "; } cout << endl; cout << "双端队列中元素总数:" << deq.s 阅读全文
posted @ 2013-07-06 12:42 Predator 阅读(1943) 评论(0) 推荐(0)
摘要:#include #include #include "TestFunction.h"#include #include using namespace std;//using ::testing::InitGoogleTest;using namespace testing;#pragma comment(lib, "gtestd.lib")void main(int argc, char **argv){ /*priority_queue pqe; pqe.push(10); pqe.push(15); pqe.push(18); pqe.push( 阅读全文
posted @ 2013-07-06 12:41 Predator 阅读(228) 评论(0) 推荐(0)