C语言产生随机数
2024-09-09 15:40:25
rand产生随机数
- #include"stdio.h"
- #include"stdlib.h"
- void main()
- {
- int i;
- for(i=0;i<5;i++)
- printf("%d ",rand()%100);
- printf("\n");
- }
srand设置随机事件的种子函数
- #include"stdio.h"
- #include"stdlib.h"
- #include"time.h"
- void main()
- {
- int i;
- time_t t;
- srand((unsigned) time(&t));
- for(i=0;i<5;i++)
- printf("%d ",rand()%100);
- printf("\n");
- }
本文出自 “阿凡达” 博客,请务必保留此出处http://shamrock.blog.51cto.com/2079212/735847
最新文章
- 设置DIV块元素在浏览器页面中垂直居中
- Hadoop 面试题之Hbase
- PHP 过滤 及 字符转换 函数
- 浏览器检测navigator 对象
- 《单页Web应用--温故JavaScrpt》学习笔记整理
- Python解决codeforces ---- 1
- lightoj 1010
- WebApp触屏版网站开发要点
- Ubuntu上安装QQ2015
- BZOJ 1212 HNOI 2004 L语言 Trie树
- CentOS python升级到3.5时yum报错
- 老李分享:robotium常用API 1
- [转]Docker基础-使用Dockerfile创建镜像
- xtrabackup 在线主从搭建
- Python中的exec、eval使用实例
- AngularJs 指令中 的Scope属性
- mvn编译
- [Luogu P1120]小木棍&#183;加强版
- webDriver API——第12部分WebElement
- mysqldump 命令使用