编程c++模拟疫情游戏

**

编程c++模拟疫情游戏

疫情期,写代码,我写你不写
下面直接附代码

#include<stdio.h>
#include<windows.h>
#include<time.h> 
#include<bits/stdc++.h>
using namespace std;

int somepeople=2000,chuangwei=200,shtime=7,viruspropagation=40,treatment=93,deadment=100,virusspreadingfar=1;
int immunizetime=160;
double carefully=0.33,runpeople=0.221;
/*
    新冠 2000,200,7,65,5,6,2,180,0.66 
   SARS 2000,200,7,60,93,100,1,120,0.66
  流感 2000,200,3,40,99,100,1,160,0.33*/
int illpeople=0,zhiyupeople=0,deadpeople=0;


struct people{
   
	int x,y;//x列 y行 
	int health_subhealth_ill;//health,subhealth(亚健康,即处在潜伏期(潜伏期也传染)),ill分别对应1,2,3;
	int forward;//上下左右 1,2,3,4
	int work;//步数 
	int subhealthtime,healthtime;
	int inhospital;//在,不在 1,0
	int dead;//死,活 1,0
	int firstill;//first,not 0,1
	int firstillture;//first,not 0,1
}whp[20000];

struct hospital{
   
	int x,y;
}whh[20000];

void gotoxy(int x,int y) 
{
   
	COORD  coord;
	coord.X=x;
	coord.Y=y;
	HANDLE a=GetStdHandle(STD_OUTPUT_HANDLE);
	SetConsoleCursorPosition(a,coord);
}

void ColorChoose(int color)   //颜色选择函数
{
   
	switch(color)
	{
   	
		case 1:               //天蓝色
		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_GREEN|FOREGROUND_BLUE);
		break;
		case 2:               //绿色
		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_GREEN);	
		break;
		case 3:               //黄色
		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN);
		break;
		case 4:               //红色
		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED);
		break;
		case 5:               //紫色
		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_BLUE);
		break;
		case 6:               //白色
		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_BLUE|FOREGROUND_GREEN);
		break;
		case 7:               //深蓝色
		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_BLUE);
		break;
	}
}

void spreading(){
   
	for(int i=1;i<=somepeople;i++){
   
		if(whp[i].firstill==1){
   
			whp[i].healthtime+=1;
		}
		if(whp[i].healthtime==immunizetime&&whp[i].firstill==1){
   
			whp[i].healthtime=0;
			whp[i].firstill=0;
			gotoxy(whp[i].x,whp[i].y);
			ColorChoose(6);
			printf("#"); 
		}
	}
	for(int i=1;i<=somepeople;i++){
   
		if
  • 3
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值