首页 > 代码库 > 中午无聊码的东西

中午无聊码的东西

8人双身份场狼人杀

普村*6 预言家*2 狼人*2 潜行狼*1 女巫*1 猎人*1 禁言长老*1 白痴*1 复刻*1

 1 #include<iostream>
 2 #include<ctime>
 3 #include<cstdlib>
 4 using namespace std;
 5 int x,a[10],b[10],use[16];
 6 string s[16]={"普村","普村","普村","普村","普村","普村","狼人","狼人","潜行狼","预言家","预言家","白痴","猎人","复刻","女巫","禁言长老"};
 7 int main(){
 8     freopen("随机.out","w",stdout);
 9     double random(double,double);
10     srand(unsigned(time(0)));
11     x=int(random(1,8));a[x]=1;b[x]=2;use[0]=1;use[1]=1;
12     for(int i=1;i<=7;i++){
13         if(a[i]==0){
14             x=int(random(0,15));
15             while(use[x]==1)x=int(random(0,15));a[i]=x;use[x]=1;
16             while(use[x]==1)x=int(random(0,15));b[i]=x;use[x]=1;}
17         cout<<i<<"号位的身份是"<<s[a[i]]<<"+"<<s[b[i]]<<endl<<endl;}
18     for(int i=0;i<=15;i++)if(use[i]==0){use[i]=1;a[8]=i;break;}
19     for(int i=0;i<=15;i++)if(use[i]==0){use[i]=1;b[8]=i;break;}
20     cout<<8<<"号位的身份是"<<s[a[8]]<<"+"<<s[b[8]]<<endl;
21     return 0;}
22 double random(double start, double end){
23     return start+(end-start)*rand()/(RAND_MAX+1.0);}

中午无聊码的东西