前往
大廳
主題

C/C++紀錄六.<<轉蛋機>> 2018/8/7

艾倫D索妮雅 | 2021-06-07 22:49:22 | 巴幣 0 | 人氣 152

#include<iostream>
#include<cstdlib>
#include<time.h>
//試做轉蛋機//
using namespace std;
int main()
{
int a,i;
unsigned seed;
seed=(unsigned)time(NULL);
srand(seed);
cout<<"歡迎來到萬惡的轉蛋機,快來試試你的非洲運吧(笑)"<<endl;
cout<<"請按1開始十連抽"<<endl;
  while(1)
  {
   cin>>a;
for(i=0;i<10;i++)
{
if(rand()%1000<10)
{
cout<<"恭喜抽到>>5星英靈!!!!!!"<<endl;
}
else
{
if(rand()%1000<50)
{
cout<<"恭喜抽到>>五星禮裝"<<endl;
}
else
{
if(rand()%1000<450)
{
cout<<"恭喜抽到>>3星英靈"<<endl;
}
else
{
if(rand()%1000<850)
{
cout<<"恭喜抽到>>三星禮裝"<<endl;
}
else
{
if(rand()%1000<970)
{
cout<<"恭喜抽到>>四星禮裝"<<endl;
}
else
{
cout<<"恭喜抽到>>4星英靈~~"<<endl;
}
}
}
}
}
}
cout<<endl;
cout<<"再一次10連請按1~大家課!大家課!"<<endl;
}
}

創作回應

更多創作