#include<stdio.h>
#include<time.h>
void Num(int num[],int &N);
void WritetoFile(int Num[],int n);
int ReadfromFile(int Num[]);
int Kai(int ok[],int user[],int ok_h,,int user_t);
int main()
{
int ch[6]={0},*ok=ch,temp[6]={0]},*user=temp,e,te,k;
/*ch[]是6位号码,e是特殊号码,temp[]是输入的基本号码,te是输入的特殊号码*/
key(cp,e);
printf(“请输入6个(1<=x<=35)不重复的基本号码:\n");
for(int i=0;i,6;i++)
scanf("%d",(use+i));
printf("请输入特殊号码(1<=x<=15):");
scanf("5d",&te);
··················
}
void Num[int a[],int &e)/*随机生成本期号码*/
{
int i,j,t,check;
srand(time(NULL));/*生成种子*/
for(i=0;i<6; )
{
check=0;
a[i]=rand()%33+1;
for(j=0;j<i;j++)
{
if(a[i]==a[j]) check=1;
}
if(check==0) i++;
else;
}
for(i=0;i<6;i++)
for(j=0;j<6-i;j++)
{
if(a[j]>a[j+1]
{t=a[j];a[j]=a[j+1];a[j+1]=t;}
}
e=rand()%16+1;
}
void WritetoFile(int Num[],int n]
{
FILE *fp;
if((fp=fopen("num.txt","w"))==NULL)/*以写方式打开文本文件*/
{
pintf("Failure to open num.txt!\n");
exit(0);
}
fwrite(num,sizeof(Num),n,fp); /*按数据块写文件*/
fclose(fp);
}
int ReadfromFile(int num[])
{
FILE *fp;
int i;
if((fp=fopen("num.txt","r'))==NULL) /*以读方式打开文本文件*/
{
printf("Failure to open num.txt!\n");
exit(0);
}
for(i=0;!feof(fp);i++)
{
fread(&num[i],sizeof(num),1,fp);
}
fclose(fp);
}
int Kai(int ok[],int user[],int ok_t,int user_t)
/*判断中奖情况(参数:开奖基本号码,用户基本号码,开奖特别号码,用户特殊号码)*/
{
for(i=0;i<6;i++)
{
if(ok[i]!=user[i])
break;
k++;
}
printf("\n");
if(k==6&&ok_t==user_t)
return(0);
if(k==6&&oK_t!==user_t)
return(1);
if(k==5&&ok_t=user_t)
return(2);
if(k==5&&ok_t!=user_t)
return(3);
}
··············
这是还没写好的程序,参考,只是大致有那么个思路而已,,,啊啊啊,实在是编不下去了!!!!怎么没人理会,摆摆写好的程序啊!
亲们,动起来吧!