生成随机数的案例

 1 #include<stdio.h>
 2 #include<math.h>
 3 #include<stdlib.h>
 4 #include<time.h>
 5 int main()
 6 {
 7     int i,j;
 8     freopen("data.in","w",stdout);
 9     srand((int)time(0));
10     for(i=1;i<=100000;i++)
11     {
12         j=((int)(rand()*1000.0))%3;
13         if(j==0)
14             printf("u\n");
15         else if(j==1)
16             printf("f\n");
17         else printf("d\n");
18     }
19     return 0;
20 }

 

posted on 2013-12-28 10:41  华山青竹  阅读(267)  评论(0)    收藏  举报

导航