#include
using namespace std;
#pragma comment(lib, "winmm.lib")
#include
#include
#include
#include
#include
void dsptime(const struct tm* ptm)
{
cout<
time_t nowtime;
nowtime=time(NULL);//获取时间1970年1月1日00:00:00到当前时刻的秒数
struct tm *local;//注意类型是tm struct 只是表示是结构体,tm才是结构体名称
local=localtime(&nowtime);//将秒数转化成本地时间,并转成struct tm类型,该类型的各数据成员分别表示年月日时分秒。
dsptime(local);//显示时间
srand(time(NULL));//产生时间种子
int n;
n=rand()%20;//产生随机数
cout<
{
dsptime(local);
}
如果将函数外的东西加到主函数里就对了,为什么??有什么办法可以让那些东西在主函数外定义吗?