生成随机数的案例

 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
");
15         else if(j==1)
16             printf("f
");
17         else printf("d
");
18     }
19     return 0;
20 }
原文地址:https://www.cnblogs.com/huashanqingzhu/p/3495081.html