c++_狼人杀升级版

server/2024/9/23 7:21:56/
#include <bits/stdc++.h>
#include <windows.h>
#include <conio.h>
#include <stdlib.h>
#include <stdio.h>
#define random(a,b) (rand()%(b-a+1)+a)
using namespace std;//命名空间
int a[6]={0,0,0,0,0,0};
struct node{string sf;
}sfs[4];
void wolf(){int x;x= random(1,6);a[x-1]=3;return ;
}
void yu(){int x,y=0;while(y==0){x= random(1,6);if(a[x-1]==0){y=1;a[x-1]=1;return ;}}
}
void fa(){int x,y=0;while(y==0){x= random(1,6);if(a[x-1]==0){y=1;a[x-1]=2;return ;}}
}
void printsetence(string &text, int interval) {int n = text.length();for (int i=0; i<n; i++) {cout<<text[i];Sleep(interval);}return;
}
int main(){//主函数
while(1){sfs[0].sf="平民";sfs[1].sf="预言家";sfs[2].sf="法师";sfs[3].sf="狼";cout<<" 狼 :1 平:3 预:1 法:1" <<endl;system("color 87") ;system("pause") ;system("cls");srand((unsigned)time(NULL));wolf();srand((unsigned)time(NULL));fa();srand((unsigned)time(NULL));yu();string text = "你是1号,你的身份是:";printsetence(text,25);cout<<sfs[a[0]].sf<<endl;system("color 87") ;system("pause") ;system("cls");int tian=0; while(1){tian++;cout<<"第"<<tian<<"夜";system("color 87") ;system("pause") ;system("cls");int flag=0;if(a[0]==3){flag=1;int shu;cout<<"你要刀几号?"<<endl;cin>>shu;a[shu-1]+=4;int c=random(1,2);	if(c==1){int flagg=0;while(flagg==0) {srand((unsigned)time(NULL));int d=random(1,6);if(a[d-1]<4){flagg=1;a[d-1]+=4;}}}else{int d=6; while(d--){if(a[d]>=4){a[d]-=4;break;}}}system("color 87") ;system("pause") ;system("cls");}else if(a[0]==2){cout<<"今晚你要毒还是救";string shu1;cin>>shu1;system("color 87") ;system("pause") ;system("cls");if(shu1=="毒"){cout<<"你要毒几号" ;int shu;cin>>shu;a[shu-1]+=4;}else{cout<<"你要救几号" ;int shu; cin>>shu;if(a[shu-1]>=4){a[shu-1]-=4;}}int flagg=0;while(flagg==0) {srand((unsigned)time(NULL));int b=random(1,6);if(a[b-1]<4){flagg=1;a[b-1]+=4;}}system("color 87") ;system("pause") ;system("cls");}else if(a[0]==1){cout<<"今晚你要预言几号";int shu;cin>>shu;system("color 87") ;system("pause") ;system("cls");cout<<"他的身份是";cout<<sfs[a[shu-1]].sf<<endl;int flagg=0;while(flagg==0) {srand((unsigned)time(NULL));int b=random(1,6);if(a[b-1]<4){flagg=1;a[b-1]+=4;}}int c=random(1,2);	if(c==1){flagg=0;while(flagg==0) {srand((unsigned)time(NULL));int d=random(1,6);if(a[d-1]<4){flagg=1;a[d-1]+=4;}}}else{int d=6; while(d--){if(a[d]>=4){a[d]-=4;break;}}}system("color 87") ;system("pause") ;system("cls");}else{int flagg=0;while(flagg==0) {srand((unsigned)time(NULL));int b=random(1,6);if(a[b-1]<4){cout<<"狼人今晚杀了"<<b<<endl; flagg=1;a[b-1]+=4;}}int c=random(1,2);	if(c==1){int flagg=0;while(flagg==0) {srand((unsigned)time(NULL));int d=random(1,6);if(a[d-1]<4){cout<<"法师今晚杀了"<<d<<endl; flagg=1;a[d-1]+=4;}}}else{int d=6;while(d--){if(a[d]>=4){cout<<a[d]<<"法师今晚救了"<<d+1<<" "<<endl; a[d]-=4;cout<<a[d];break;}}}}int k=0;for(int i=0;i<6;i++)if(a[i]<4&&a[i]!=3)k=1;if(k==0){cout<<"狼胜"; system("color 87") ;system("pause") ;system("cls");break;}int sum=0,hh=0;cout<<"天亮了,过了今晚还剩";for(int i=0;i<6;i++){if(a[i]<4){cout<<i+1<<"号"<<" ";sum++;}else if(i==0){system("pause") ;system("cls");cout<<"你被杀了"<<endl;system("pause") ;system("cls");hh=1;}else if(a[i]==7){cout<<"狼死了";system("color 87") ;system("pause") ;system("cls");hh=1;}} if(hh==1){system("color 87") ;system("pause") ;system("cls");break;}system("color 87") ;system("pause") ;system("cls");int mx=0,mxx,n,piao[6]={0,0,0,0,0,0};cout<<"请投票"<<endl;cin>> n;piao[n-1]++;sum-=1;while(sum--){srand((unsigned)time(NULL));piao[random(1,6)-1]++;}for(int i=0;i<6;i++){cout<<i+1<<"号:"<<piao[i]<<"票 "; if(mx<piao[i]){mx=piao[i];mxx=i+1;}}cout<<endl;cout<<mxx<<"号出局"<<endl;if(mxx-1==0){system("pause") ;system("cls");cout<<"你被票了"<<endl;system("pause") ;system("cls");return 0;}a[mxx-1]+=4;if(a[mxx-1]==7){cout<<"他是狼"; system("color 87") ;system("pause") ;system("cls");break;}int o=0;for(int i=0;i<6;i++)if(a[i]<4&&a[i]!=3)o=1;if(o==0){cout<<"狼胜"; system("color 87") ;system("pause") ;system("cls");break;}}
}return 0;//返回值
}

狼人杀:c++_游戏_狼人杀-CSDN博客


http://www.ppmy.cn/server/98319.html

相关文章

Java中的分布式日志与追踪

随着微服务架构的流行&#xff0c;分布式系统变得越来越复杂。在分布式系统中&#xff0c;日志和追踪是两个关键的工具&#xff0c;用于监控系统的健康状态、故障排除和性能优化。本文将详细探讨Java中的分布式日志与追踪&#xff0c;介绍相关的技术和工具&#xff0c;并通过代…

清韵千言-小思——一个强大的AI大语言模型接口

介绍 清韵千言-小思 是一款由我们的团队自主研发的大规模语言模型接口。该模型不仅能够处理各种自然语言任务&#xff0c;而且它的大部分能力已经超越了GPT-3.5等模型。尽管如此&#xff0c;小思也有一些特定的限制条件&#xff0c;比如不支持上下文记忆、不支持并发请求等。下…

SX_SM2002_RTC模块的烧录与调试_8

1、烧录&#xff1a; 首先git上下载项目到本地会下载所有项目&#xff0c;包括所有分支内容&#xff0c;烧录的话得在对应开发板子的分支下烧录&#xff0c;因为各分支的代码是不同的&#xff0c;得在本地切换到相应板子的分支烧录&#xff0c;切换后本地文件也会做相应改变 切…

JVM详解(个人学习笔记)

前言 本篇文章为我个人在学习JVM时所记录的笔记&#xff0c;内容把部分来自《深入理解java虚拟机》一书&#xff0c;笔记中总结了JVM中一些比较重要的知识点并作出了自己的解释。 java运行时数据区域 程序计数器&#xff08;线程内私有&#xff09; 程序计数器&#xff08;P…

使用 Ultralytics YOLO 进行模型预测的详细细节介绍

使用 Ultralytics YOLO 进行模型预测的详细细节介绍 使用 Ultralytics YOLO 进行模型预测简介预测推理数据可以是哪些来源推理参数可视化参数图像和视频格式图像格式 视频格式处理结果BoxesMasksKeypointsProbsOBB绘制结果plot() 方法参数线程安全推理线程安全推理 流媒体源 fo…

Python中各类常用内置转换函数

Python中各类常用内置转换函数 函数功能说明int(x)将 x 转换为整数类型float(x)将 x 转换为浮点数类型str(x)将 x 转换为字符串repr(x)将 x 转换为表达式字符串eval(str)计算在字符串中的有效Python表达式&#xff0c;并返回一个对象list(s)将序列 s 转换为一个列表tuple(s)将…

ARM专栏目录

Arm发布Cortex X925、A725、A520&#xff0c;Armv9.2架构 【目录】Armv8/Armv9付费专栏 中华人民共和国密码行业标准-各类标准文档下载 一文帮你梳理ARM基础概念 ARM VS X86 处理器构架一文读懂 arm架构-从入门到精通 armv8/armv9 MMU深度学习 多核多cluster多系统之间缓存一致…

Mybatis-plus乐观锁

为什么要用锁 原因是当两个线程并发修改同一条数据时候 例如有条数据 id 1 count(金额/数量) 500 有两个线程都在查询数据库 查出来都是 1 500 现在两个线程都要修改这条数据 在原来基础上20 和30 那么理论来讲应该是550 可是实际有可能是530 原…