Chinaunix首页 | 论坛 | 博客
  • 博客访问: 410279
  • 博文数量: 54
  • 博客积分: 1186
  • 博客等级: 少尉
  • 技术积分: 668
  • 用 户 组: 普通用户
  • 注册时间: 2011-03-11 04:57
文章分类

全部博文(54)

文章存档

2013年(1)

2012年(6)

2011年(47)

我的朋友

分类: C/C++

2011-05-10 12:43:09

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <sys/time.h>
  5. int main()
  6. {
  7.     struct timeval st;
  8.     gettimeofday( &st, NULL );
  9.     srand(st.tv_usec);
  10.     printf( "%d -> %d\n", st.tv_usec, 1 + rand() % 9 );
  11.     return 0;
  12. }

  13. /*打印结果*/

  14. /*
  15. $ ./a.out
  16. 9
  17. $ ./a.out
  18. 6
  19. $ ./a.out
  20. 3
  21. $ ./a.out
阅读(1630) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~