闲得蛋疼写了个双色球的机选号,求指点。
c语言吧
全部回复
仅看楼主
level 1
代码如下。。
#include <stdio.h>
#include <time.h>
int main()
{
     int i;// the number of the array;
     int key;
     int dcbr[34];
     int dcbb[17];
     //set the value;
     for (i = 1; i < 34; i++)
         dcbr[i] = i;
     for (i = 1; i < 17; i++)
         dcbb[i]     = i;
     srand((unsigned)time(NULL));
     //reb ball;
     for(i = 1; i < 7;i++){
         printf("第 %d 个红球:",i);
         key = (rand()%(34-i)) + 1;
         printf("%d\n",dcbr[key]);
         for (;key <(34-i);key++)
             dcbr[key] = dcbr[key+1];
         dcbr[34-i] = 0;
     }
     //blue ball
     printf("蓝球:");
     key =   rand()%16 + 1;
     printf("%d\n",dcbb[key]);
     return 0;    
}
2010年05月10日 03点05分 1
1