随笔分类 -  C++

C++技巧
摘要:文件打开文件时判断文件是否存在:ifstream f("123.txt");if (!f) cout#includeusing namespace std;int date2week(int date){ time_t rawTime; time(&rawTime); struct tm* timeInfo = localtime(&rawTime); timeInfo->tm_year = date / 10000 - 1900; timeInfo->tm_mon = date/100 %100 - 1; timeInfo->tm_mda 阅读全文

posted @ 2013-06-28 21:25 赛欧拉 阅读(230) 评论(0) 推荐(0)

进程共享数据
摘要:程序A中共享数据, 代码:// 内存共享数据A.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include "内存共享数据A.h"#includeusing namespace std;#ifdef _DEBUG#define new DEBUG_NEW#undef THIS_FILEstatic char THIS_FILE[] = __FILE__;#endif////////////////////////////////////// 阅读全文

posted @ 2013-06-24 23:05 赛欧拉 阅读(322) 评论(0) 推荐(0)

八数码问题
摘要:#pragma warning(disable:4786)#include#include#include#includeusing namespace std;int gOrient[4][2] = {-1,0, 1,0, 0,-1, 0,1};//-----------------------------------------------------------------------------class State{public: int findPos(int n) const; bool operator calculated; priority_queue ... 阅读全文

posted @ 2013-06-23 11:09 赛欧拉 阅读(275) 评论(0) 推荐(0)