C++彩票模拟器
真的好久没更新编程相关的视频了,今天我就更一期。
链接:BV1W34y1j7ND(发专栏时可能没发)

代码:
代码块版:
普通版:
#include <iostream>
#include <ctime>
#include <cmath>
#include <cstdlib>
#include <io.h>
#include <direct.h>
#include <fstream>
#include <unistd.h>
#include <string>
using namespace std;
int main()
{
srand(int(time(0)));
int a,add,daan[6],daans,chose[6],choses,right[6],rights;
cout<<"欢迎使用彩票机!请选择功能:1查看规则 2开始下注"<<endl;
cin>>a;
system("cls || clear");
if(a==1)
{
cout<<"规则:26选7,其中有6个普通号码(a),1个特殊号码(b)"<<endl;
sleep(1);
cout<<"奖项:\n全中 999万\n5a+1b 888万\n4a+1b或6a 666万\n2a或3a或4a或5a或3a+1b或2a+1b 1000\n1a+1b 66\n其余:没奖"<<endl;
sleep(1);
cout<<"备注:可以机选"<<endl;
sleep(1);
cout<<"重新运行以开始……"<<endl;
exit(0);
}
if(a==2)
{
cout<<"请选择模式:1机选 2自选"<<endl;
cin>>a;
system("cls || clear");
if(a==1)
{
for(int i=0;i<=5;i++)
{
chose[i]=rand()%26+1;
}
choses=rand()%26+1;
cout<<"下面公布机选结果:"<<endl;
for(int i=0;i<=5;i++)
{
cout<<chose[i]<<" ";
}
cout<<choses;
sleep(5);
system("cls || clear");
}
if(a==2)
{
for(int i=0;i<=5;i++)
{
cout<<"请输入第"<<i+1<<"个数字:(1<=n<=26)"<<endl;
cin>>chose[i];
}
cout<<endl<<"请输入第7个数字:(1<=n<=26)"<<endl;
cin>>choses;
system("cls || clear");
}
cout<<"选号完成!"<<endl;
sleep(2);
for(int i=0;i<=5;i++)
{
daan[i]=rand()%26+1;
}
daans=rand()%26+1;
cout<<"即将开奖!"<<endl;
for(int i=0;i<=5;i++)
{
cout<<"第"<<i+1<<"个数字将开奖,请输入任意数字开奖:"<<endl;
cin>>a;
system("cls || clear");
cout<<"第"<<i+1<<"个数字是:"<<daan[i]<<endl;
sleep(3);
system("cls || clear");
}
cout<<"特殊数字将开奖,请输入任意数字开奖:"<<endl;
cin>>a;
system("cls || clear");
cout<<"特殊数字是:"<<daans<<endl;
sleep(3);
system("cls || clear");
cout<<"开奖环节结束:即将公示你的奖项:"<<endl;
for(int i=0;i<=5;i++)
{
if((daan[i]==chose[0])or(daan[i]==chose[1])or(daan[i]==chose[2])or(daan[i]==chose[3])or(daan[i]==chose[4])or(daan[i]==chose[5]))
{
right[i]=1;
}
else
{
right[i]=0;
}
add=add+right[i];
}
if(daans==choses)
{
rights=1;
}
else
{
rights=0;
}
cout<<"普通号码中奖数:"<<add<<endl<<"特殊号码:(1中0不中)"<<rights<<endl;
sleep(2);
cout<<"你的获奖情况和奖金情况(a为普通号码,b为特殊号码):";
if(add==6 and rights==1)
{
cout<<"全中 999万"<<endl;
}
else if(add==5 and rights==1)
{
cout<<"5a+1b 888万"<<endl;
}
else if((add==4 and rights==1)or(add==6 and rights==0))
{
cout<<"4a+1b或6a 666万"<<endl;
}
else if((add==2)or(add==3)or(add==4 and rights==0)or(add==5 and rights==0))
{
cout<<"2a或3a或4a或5a或3a+1b或2a+1b 1000"<<endl;
}
else if(add=1 and rights==1)
{
cout<<"1a+1b 66"<<endl;
}
else
{
cout<<"其余:没奖"<<endl;
}
sleep(2);
cout<<"开奖完成!"<<endl;
sleep(2);
cout<<"感谢使用!"<<endl;
sleep(2);
exit(0);
}
}

本期视频专栏到此结束,感谢观看!
pis:文章中的“钱”仅为虚拟,不真实提供。