书山有径勤为路>>>>>>>>

<<<<<<<<学海无涯苦作舟!

随笔分类 -  C Math

rand&&srand
摘要:rand()功能:伪随机数发生器库: stdlib.h用法:需要先调用srand初始化,一般用当前日期初始化随机数种子, 这样每次执行代码都可以产生不同的随机数。View Code #include "iostream"#include "cstdio"#include "ctime"using namespace std;int main(){ srand((unsigned)time(NULL)); for(int i=0; i<20; i++) { cout<<rand()%10<<endl; }} 阅读全文

posted @ 2012-04-19 23:16 More study needed. 阅读(161) 评论(0) 推荐(0)

导航

书山有径勤为路>>>>>>>>

<<<<<<<<学海无涯苦作舟!