首页
论坛
登录
立即注册
搜索
首页
›
技术
›
杂七杂八
›
关于中的一些函数
发新帖
回复
javaee
普通会员
225648
帖子
335
回复
349
积分
[杂七杂八]
关于中的一些函数
楼主
发表于 2017-09-30 09:57:39
|
查看: 432
|
回复: 0
1
关于<time.h>的一些函数
2
3
1.
使用当前时间作种子,生成随机数
4
5
#include
<stdio.h>
6
#include
<stdlib.h>
7
#include
<time.h>
8
9
int
gen_rand_num()
10
{
11
static
int
first_time =
1
;
12
13
if
(first_time)
14
{
15
first_time =
0
;
16
srand((
unsigned
int
)time(
NULL
));
17
}
18
19
return
rand();
20
}
21
22
2.
打印当前时间
23
24
#include
<stdio.h>
25
#include
<stdlib.h>
26
#include
<time.h>
27
28
int
print_time()
29
{
30
time_t
now;
31
32
now = time(
NULL
);
33
printf(
"
%s
"
, ctime(&now));
34
return
0
;
35
}
相关帖子
•
C#特性详解
•
MVC编程实例
•
前端web开发的MVC模式
•
MVC项目实例
•
With AS 公共查询块
•
用NuGet安装NewtonSoft.json
•
SVN安装配置与使用转
•
利用Emgu.CV实现人脸识别详解 (C#)
•
我来评三国
•
常用编程网站
上一篇:
从N
下一篇:
压缩编码算法评价 PSNR
您需要登录后才可以回帖
登录
|
立即注册
发表回复
请登录后发表回复
触屏版
|
电脑版
技术支持
历史网
V2.0
© 2016-2017
返回顶部