2010年10月20日

// 产生10到100随机数

摘要: // 产生10到100随机数//#include "stdafx.h"#include "stdlib.h"#include "time.h"int main(int argc, char* argv[]){ int i;int f,g;srand((unsigned)time(NULL));for(i=0;i<100;i++){ f=rand()%(100-10+1); g=f+10; printf("%d/n",g);}return 0;} 阅读全文

posted @ 2010-10-20 23:30 IT@民工 阅读(247) 评论(0) 推荐(0) 编辑

产生0-1随机数 VC++

摘要: #include "stdafx.h"#include "stdlib.h"#include "time.h"int main(int argc, char* argv[]){ int i;double f,g;srand((unsigned)time(NULL));for(i=0;i<100;i++){ f=(double)(rand()%11); //不包括1就 %10就行了 g=f/10; printf("%f/n",g);}return 0;} 阅读全文

posted @ 2010-10-20 23:17 IT@民工 阅读(260) 评论(0) 推荐(0) 编辑

导航