体育彩票的模拟生成和兑奖c程序
来源:互联网 发布:淘宝钻展位置 编辑:程序博客网 时间:2024/05/01 03:51
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#define MM 7
#define NN 36
typedef int ElemTp;
typedef struct
{
ElemTp elem[MM+1];
int len;
} VoteTp;
typedef struct
{
ElemTp elem[NN+1];
int len;
} SourceTp;
SourceTp source;
InitializeVote(VoteTp *vote);
InitializeSource(SourceTp *source);
void SeqInsertVote(VoteTp *vote,int i,ElemTp x);
int SeqLocate(VoteTp v,ElemTp x);
VoteTp CreateAVote();
int RightNum(VoteTp vote,VoteTp answervote);
main()
{
VoteTp vote;
VoteTp answervote;
int k,i;
randomize();
InitializeSource(&source);
answervote=CreateAVote();
printf("/nPress Any Key to Continue ,0 to exit !");
printf("/n Answer Numbers: ");
for (i=1;i<=MM;i++)
printf("%3d ",answervote.elem[i]);
printf("/n Your Vote Numbers ---->>Right Numbers /n");
while (getchar()!='0')
{
vote=CreateAVote();
for (i=1;i<=MM;i++)
printf(" %-2d ",vote.elem[i]);
k=RightNum(vote,answervote);
printf(" ---->> %d /n",k);
}
}
InitializeVote(VoteTp *vote)
{
vote->len=0;
}
InitializeSource(SourceTp *Source)
{
int i;
for(i=1;i<=NN;i++)
Source->elem[i]=i;
Source->len=NN;
}
int SeqLocate(VoteTp v,ElemTp x)
{
int j=1;
while(j<=v.len&&v.elem[j]!=x)
j++;
if(j<=v.len)
return j;
else
return 0;
}
void SeqInsertVote(VoteTp *vote,int i,ElemTp x)
{
VoteTp v;
int j;
v=*vote;
if((i<1)||(i>v.len+1))
printf(" error number!");
else
{
for(j=v.len;j>=i;j--)
v.elem[j+1]=v.elem[j];
v.elem[i]=x;
v.len=v.len+1;
}
*vote=v;
}
int RightNum(VoteTp vote,VoteTp answervote)
{
int i,k;
k=0;
for (i=1;i<=MM;i++)
if(SeqLocate(vote,answervote.elem[i])>0)
k++;
return(k);
}
VoteTp CreateAVote()
{
VoteTp vote;
ElemTp k,temp;
int i;
InitializeVote(&vote);
source.len=NN;
for(i=1;i<=MM;i++)
{
k=random(source.len)+1;
SeqInsertVote(&vote,vote.len+1,source.elem[k]);
temp=source.elem[k];
source.elem[k]=source.elem[source.len];
source.elem[source.len]=temp;
source.len=source.len-1;
}
return vote;
}
- 体育彩票的模拟生成和兑奖c程序
- 体育彩票随机生成程序
- 彩票兑奖小程序
- 一个简单的体育彩票模拟机与分析机
- 程序算法之构造法之(体育彩票排列3模拟抽奖程序)
- 论体育彩票的随机数
- 海明码生成模拟程序(c)
- C++: 对双线程下载程序的封装和模拟
- C++: 对双线程下载程序的封装和模拟
- 用C语言模拟随机数的生成
- Random类引出的体育彩票的故事!
- C生成最小的程序
- C生成最小的程序
- C程序的生成过程
- 一个c#Framework模拟堆栈的程序
- Nasm 汇编程序和Turboc的C程序混合编程,生成.com程序的方法
- C程序的生成要经历
- C程序中唯一序列号的生成
- Jigdo: 下载 Debian 光盘的新方法
- [转]Delphi 7 and Web Service Global Activation Model Fix
- 试一下
- 第一次使用blog
- 关于字节对齐问题的解释.
- 体育彩票的模拟生成和兑奖c程序
- debug使用手册
- 走进程序世界的田园------引导扇区释疑
- 中间件
- Windows 2000 CMD命令大全
- Windows server 2003设置使用必备技巧集
- SOLARIS用户命令中英文对照参考
- Debug-PC之开山老祖
- C语言