求大神指教,小弟新手
/* 乐透号码开奖游戏*/#include <stdio.h>
#include<stdlib.h>
#include <time.h>
int SeqSearch(int Target,int ,int *arr,int arr_index);
void generate_lotto(int *spec_num,int *arr,int arr_index);
/* 循序搜寻*/
int SeqSearch(int Target,int *arr,int arr_index)
{
int i;
for (i=0;i<arr_index;i++)
if(Target==arr[i]) /*找到了*/
return i ;
return -1; /*完全找不到*/
}
/*产生乐透号码*/
void generate_lotto(int *spec_num,int *arr,int arr_index)
{
int i ,generate_num;
srand((unsigned) time(NULL));
for (i=0;i<arr_index;i++)
{
generate_num=rand()%42+1;
while (SeqSearch(generate_num, arr, i+1)!=-1) /*是否重复*/
{
generate_num=rand()%42+1;
}
arr[i]=generate_num;
}
generate_num=rand()%42+1;
while (SeqSearch(generate_num,arr,i)!=-1) /*特别号是否与其他号码重复*/
{
generate_num=rand()%42+1;
}
*spec_num=generate_num;
}
/*******************************************************/
int main(void)
{
int lotto[6],i,special;
generate_lotto(&special,lotto,6);
printf("lotto number is following:\n");
for (i=0; i<6; i++)
printf("%d\t",lotto[i]);
printf("\n");
printf("special number:%d\n",special);
/* system("pause") */
}
红色行提示参数少了一个,为什么??求大神指教。