彩票(最新版本)
2025-02-10 15:16:52
发布于:浙江
//V1.5.6 25021009版
#include<iostream>
#include<stdlib.h>
#include<windows.h>
#include<time.h>
using namespace std;
int main()
{
srand(time(0));
a:
cout<<"彩票参数:";
bool zj=0;
int n,sum=0;
cin>>n;
int a[n];
for(int i=1;i<=n;i++)
{
a[i-1]=rand()%1000+1;
cout<<i<<':'<<a[i-1]<<' '<<endl;
}
cout<<endl<<"-----"<<endl;
for(int i=1;i<=n;i++)
{
for(int j=i+1;j<=n;j++)
{
if(a[i-1]==a[j-1])
{
cout<<i<<' '<<j<<" YES\n";
zj=1;
sum++;
}
}
}
if(zj==0) cout<<"NO\n";
else cout<<"共计"<<sum<<"个中奖。\n";
cout<<"-----\n";
goto a;
return 0;
}
其中“彩票参数”指的是生成几个随机数,彩票参数越大中奖概率越大。
这里空空如也
有帮助,赞一个