#include<bits/stdc++.h>
using namespace std;
char kz;
int a[10],n,w=0,x=0,d=100;
int main(){
cout<<"欢迎来到抽奖系统,每抽一次奖,将会使用5个点,有高达99.9%的机率中奖!输入’k‘即可开始"<<endl;
cin>>kz;
while(kz=='k'&&d!=0)
{
srand((unsigned)time(NULL));
for(int i=1;i<=10;i++)
{
a[i]=rand();
}
sort(a+1,a+10+1);
n=rand();
while(n>10)
{
n=rand();
}
if(a[n]>=a[6]) {cout<<endl<<"你抽到了:武器卡"<<endl;w++;d=d-5;}
else {if(a[n]<=a[5]&&a[n]>=a[1]) cout<<endl<<"你抽到了:效果卡"<<endl;x++;d=d-5;}
else cout<<endl<<"谢谢参与,下次再来"<<endl;d=d-5;
cout<<"继续or退出?继续请按k,退出请按t"<<endl;
cin>>kz;
if(kz=='t')
{
return 0;
}
if(d==0)
{
cout<<"哎呀,点数不够了,去发育亿下吧!";
}
}
return 0;
}
#include<bits/stdc++.h>
using namespace std;
char kz;
int a[10],n,w=0,x=0,d=100;
int main(){
cout<<"欢迎来到抽奖系统,每抽一次奖,将会使用5个点,有高达99.9%的机率中奖!输入’k‘即可开始"<<endl;
cin>>kz;
while(kz=='k'&&d!=0)
{
srand((unsigned)time(NULL));
for(int i=1;i<=10;i++)
{
a[i]=rand();
}
sort(a+1,a+10+1);
n=rand();
while(n>10)
{
n=rand();
}
if(a[n]>=a[6]) {cout<<endl<<"你抽到了:武器卡"<<endl;w++;d=d-5;}
else {if(a[n]<=a[5]&&a[n]>=a[1]) cout<<endl<<"你抽到了:效果卡"<<endl;x++;d=d-5;}
cout<<endl<<"谢谢参与,下次再来"<<endl;d=d-5;
cout<<"继续or退出?继续请按k,退出请按t"<<endl;
cin>>kz;
if(kz=='t')
{
cout<<"xg:"<<x<<"wq:"<<w;
return 0;
}
if(d==0)
{
cout<<"哎呀,点数不够了,去发育亿下吧!"<<endl;
cout<<"xg:"<<x<<"wq:"<<w;
}
}
return 0;
}
帮你修改好了
#include <iostream>
#include <ctime>
#include <algorithm>
#include <vector>
using namespace std;
int main()
{
const int N = 10;
char kz;
int a[N], n, w = 0, x = 0, d = 100;
srand(time(nullptr));
cout << "欢迎来到抽奖系统,每抽一次奖,将会使用5个点,有高达99.9%的机率中奖!输入’k‘即可开始" << endl;
cin >> kz;
while (kz == 'k')
{
for (int i = 0; i < N; i++)
a[i] = rand();
sort(a, a + N);
n = rand() % N;
if (a[n] >= a[6])
{
cout << "你抽到了:武器卡" << endl;
w++;
}
else if (a[n] <= a[5] && a[n] >= a[1])
{
cout << "你抽到了:效果卡" << endl;
x++;
}
else
{
cout << "谢谢参与,下次再来" << endl;
}
d = d - 5;
cout << "继续or退出?继续请按k,退出请按t" << endl;
cin >> kz;
if (kz == 't')
break;
if (d <= 0)
{
cout << "哎呀,点数不够了,去发育亿下吧!";
break;
}
}
return 0;
}