#include
using namespace std;
class Date; //对Date类的提前引用声明
class Time
{
public:
Time(int,int,int);
void add_a_second(Date &); //增加1秒,1秒后可能会到了下一天,乃到下一月、下一年
void display(Date &); //显示时间,...
分类:
其他好文 时间:
2014-06-08 18:17:22
阅读次数:
216
#include
#include
#include
using std::cout;
using std::endl;
int main(void){
//使用默认种子值产生随机数,每次产生的都一样
cout << rand() << " " << rand() << " " << rand() << endl;
//使用新种子产生随机数,每次都不一样
...
分类:
编程语言 时间:
2014-06-08 17:26:30
阅读次数:
215
#include
#include
using namespace std;
class CPoint//点类
{
private:
double x;//横坐标
double y;//纵坐标
public:
//使用初始化表初始化数据成员
CPoint(double xx=0,double yy=0):x(xx),y(yy){}
...
分类:
其他好文 时间:
2014-06-08 15:38:11
阅读次数:
299
题目来源:Light OJ 1278 Sum of Consecutive Integers
题意:N拆分成连续整数和的方案数
思路:奇因数的个数
#include
#include
#include
#include
using namespace std;
//筛素数
const int maxn = 10000010;
bool vis[maxn];
int prime[10...
分类:
其他好文 时间:
2014-06-08 15:34:09
阅读次数:
295
模式定义:
单例模式确保一个类只有一个实例,并提供一个全局访问点。
模式结构:
单例模式编程实现及执行结果:
#include
using namespace std;
单例类
class Sigleton
{
public:
static Sigleton* getInstance();
private:
Sigleton(){}
stat...
分类:
编程语言 时间:
2014-06-08 15:08:54
阅读次数:
242
题目链接:点击打开链接
= - =以前的三分姿势不正确居然没有被卡掉,,,太逗。。
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
#define M 200004
#define N ...
分类:
其他好文 时间:
2014-06-08 15:04:12
阅读次数:
338
根据下面关系式,求圆周率的值,直到最后一项的值小于给定阈值。
输入格式:
输入在一行中给出小于1的阈值。
输出格式:
在一行中输出满足阈值条件的近似圆周率,输出到小数点后6位。
输入样例:
0.01
输出样例:
3.132157
#include
#include
using namespace std;
int main() {
...
分类:
其他好文 时间:
2014-06-08 10:39:26
阅读次数:
250
题意:贪吃蛇的题目
思路:BFS+状态的记录,坑了无数发,#include
#include
#include
using namespace std;
const int MAXN = 500000;
bool flag[8],vis[25][25],mp[21][21][16384];
int n,m,l;
int xx[4]={-1,0,1,0}; // up,right,dow,left...
分类:
其他好文 时间:
2014-06-08 10:13:19
阅读次数:
204
先在这里记录一下代码!原理将来再补吧!
这个算法算是有一个致命的弱点吧!那就是如果元素的个数达不到2^n个的话,要填充!#include
using namespace std;
void SortDown(int , int);
void MergeUp(int, int);
void MergeDown(int, int);
void Exchange(int , int);
vo...
分类:
其他好文 时间:
2014-06-08 09:15:43
阅读次数:
225
题目来源:Light OJ 1251 Forming the Council
题意:若干了条件至少满足一个 求是否有方案 输出任意一种可能的方案 留下的人的个数
思路:2-SAT基础题
#include
#include
#include
using namespace std;
const int maxn = 100010;
int n, m;
vector G[maxn*2];...
分类:
其他好文 时间:
2014-06-08 08:15:18
阅读次数:
261