随机数及atoi
注意C++11有更强大的方法!
//随机数及atoi
#include
int abs( int num );//功能: 函数返回参数num.的绝对值。
double atof( const char *str );//功能:将字符串str转换成一个双精度数值并返回结果。
int atoi( const char *str );//功能:将字符串str转换成一个整数并返回结果。
void srand(unsigned seed);// 初始化随机数发生器
int rand();// 产生一个随机数并返回这个数
time相关
#include <iostream>
using namespace std;
time_t getMorningTime()
{
time_t t = time(NULL);
cout<<t<<endl;
cout<<timezone<<endl;
// GMT+0
struct tm * tm= localtime(&t);
cout<<tm->tm_hour<<endl;
tm->tm_hour = 0;
tm->tm_min = 0;
tm->tm_sec = 0;
// 转为 GMT+8
return mktime(tm);
}
int main()
{
//cout<<_timezone ;
cout << getMorningTime() << endl;
return 0;
}