time_t t = time(0);
char tmp[64];
strftime( tmp, sizeof(tmp), "%Y/%m/%d %X %A 本年第%j天 %z",localtime(&t) );
cout<<tmp;#include <windows.h>
#include <stdio.h>
int main( void )
{
SYSTEMTIME sys;
GetLocalTime( &sys );
printf( "%4d/%02d/%02d %02d:%02d:%02d.%03d 星期%1d\n",sys.wYear,sys.wMonth,sys.wDay,sys.wHour,sys.wMinute, sys.wSecond,sys.wMilliseconds,sys.wDayOfWeek);
return 0;
}#include<stdlib.h>
#include<iostream>
using namespace std;
void main()
{
system("time");
}#include<iostream>
#include<ctime>
using namespace std;
int main()
{
time_t now_time;
now_time = time(NULL);
cout<<now_time;
return 0;
}srand(unsigned seed)通过参数seed改变系统提供的种子值,从而可以使得每次调用rand函数生成的伪随机数序列不同,从而实现真正意义上的“随机”。
/**
* 书本:【ThinkingInC++】
* 功能:类里的const
* 时间:2014年9月8日15:39:57
*/
#include<iostream>
using namespace std;
class Fred
{
const int size; //类里面的const
public:
Fred(int sz); //构造函数,等会用来初始化const
void print();
};
Fred::Fred(int sz) : size(sz) {}
void Fred::print() {cout<<size<<endl;}
int main()
{
Fred a(1), b(2), c(3);
a.print(), b.print(), c.print(); //这里我也是第一次见到可以用","来隔开
return 0;
}
原文地址:http://blog.csdn.net/cutter_point/article/details/39136821