c语言炉石传说测试数据库,炉石传说(示例代码)
#include #include
using namespacestd;intmain()
{structattendant{int exist; //是否存在空位
int health; //随从生命值
int attack; //随从攻击力
};
attendant player1[8],player2[8];for(int i = 1;i <= 7;i++)
{
player1[i].exist= 0;
}for(int i = 1;i <= 7;i++)
{
player2[i].exist= 0;
}int n,Player1 = 30,Player2 = 30,flag = 1,pos,attack,health;stringsymbol;
cin>>n;while(n--)
{
cin>>symbol;if(flag % 2 == 1)
{if(symbol=="summon")
{
cin>>pos;
cin>>attack;
cin>>health;if(Player1 <= 0 || Player2 <= 0) //判断游戏是否已经结束
{continue;
}if(player1[pos].exist == 0)
{
player1[pos].exist= 1;
player1[pos].attack=attack;
player1[pos].health=health;
}else{for(int i = 6;i >= pos;i--)
{
player1[i+ 1].exist =player1[i].exist;
player1[i+ 1].attack =player1[i].attack;
player1[i+ 1].health =player1[i].health;
}
player1[pos].exist= 1;
player1[pos].attack=attack;
player1[pos].health=health;
}
}else if(symbol == "attack")
{intgong,sou;
cin>>gong;
cin>>sou;if(Player1 <= 0 || Player2 <= 0)
{continue;
}if(sou != 0)
{
player1[gong].health= player1[gong].health -player2[sou].attack;
player2[sou].health= player2[sou].health -player1[gong].attack;if(player1[gong].health <= 0 && gong == 7)
{
player1[gong].exist= 0;
}else if(player1[gong].health <= 0 && gong < 7)
{for(int i = gong + 1;i <= 7;i++)
{
player1[i- 1].exist =player1[i].exist;
player1[i].exist= 0;
player1[i- 1].health =player1[i].health;
player1[i- 1].attack =player1[i].attack;
}
}if(player2[sou].health <= 0 && sou == 7)
{
player2[sou].exist= 0;
}else if(player2[sou].health <= 0 && sou < 7)
{for(int i = sou + 1;i <= 7;i++)
{
player2[i- 1].exist =player2[i].exist;
player2[i- 1].health =player2[i].health;
player2[i- 1].attack =player2[i].attack;
}
}
}else{
Player2= Player2 -player1[gong].attack;
}
}else if(symbol == "end")
{
flag= flag + 1;
}
}
// 玩家二回合else if(flag % 2 == 0)
{if(symbol=="summon")
{
cin>>pos;
cin>>attack;
cin>>health;if(Player1 <= 0 || Player2 <= 0)
{continue;
}if(player2[pos].exist == 0)
{
player2[pos].exist= 1;
player2[pos].attack=attack;
player2[pos].health=health;
}else{for(int i = 6;i >= pos;i--)
{
player2[i+ 1].exist =player2[i].exist;
player2[i].exist= 0;
player2[i+ 1].attack =player2[i].attack;
player2[i+ 1].health =player2[i].health;
}
player2[pos].exist= 1;
player2[pos].attack=attack;
player2[pos].health=health;
}
}else if(symbol == "attack")
{intgong,sou;
cin>>gong;
cin>>sou;if(Player1 <= 0 || Player2 <= 0)
{continue;
}if(sou != 0)
{
player2[gong].health= player2[gong].health -player1[sou].attack;
player1[sou].health= player1[sou].health -player2[gong].attack;if(player2[gong].health <= 0 && gong == 7)
{
player2[gong].exist= 0;
}else if(player2[gong].health <= 0 && gong < 7)
{for(int i = gong + 1;i <= 7;i++)
{
player2[i- 1].exist =player2[i].exist;
player2[i- 1].health =player2[i].health;
player2[i- 1].attack =player2[i].attack;
}
}if(player1[sou].health <= 0 && sou == 7)
{
player1[sou].exist= 0;
}else if(player1[sou].health <= 0 && sou < 7)
{for(int i = sou + 1;i <= 7;i++)
{
player1[i- 1].exist =player1[i].exist;
player1[i- 1].health =player1[i].health;
player1[i- 1].attack =player1[i].attack;
}
}
}else{
Player1= Player1 -player2[gong].attack;
}
}else if(symbol == "end")
{
flag= flag + 1;
}
}
}int count1 = 0,count2 = 0; //记录随从数量
for(int i = 1;i <= 7;i++)
{if(player1[i].exist == 1)
{
count1++;
}
}for(int i = 1;i <= 7;i++)
{if(player2[i].exist == 1)
{
count2++;
}
}if(Player1 <= 0)
{
cout<< "-1" << "";
}else if(Player2 <= 0)
{
cout<< "1" << "";
}else{
cout<< "0" << "";
}
cout<< Player1 << "";
cout<< count1 << " ";if(count1 > 0)
{for(int i = 1;i <= 7;i++)
{if(player1[i].exist == 1)
{
cout<< player1[i].health <
}
}
cout<< "";
}else{
cout<< "";
}
cout<< Player2 << "";
cout<< count2 << " ";if(count2 > 0)
{for(int i = 1;i <= 7;i++)
{if(player2[i].exist == 1)
{
cout<< player2[i].health <
}
}
cout<< "";
}else{
cout<< "";
}return 0;
}
c语言炉石传说测试数据库,炉石传说(示例代码)相关推荐
- mysql数据库集群配置_使用MySQL-Cluster搭建MySQL数据库集群(示例代码)
1.MySQL集群的作用: - 解决访问节点的单点故障 - 数据存储节点的单点故障 - 解决数据存储节点数据备份问题 2.集群: 使用一组服务器提供相同的服务 3.关于MySQL-Cluster: M ...
- C语言循环选择还有,C语言第五讲,语句 顺序循环选择.(示例代码)
C语言第五讲,语句 顺序循环选择. 一丶语句的简明了解 我们知道,在编写C语言程序的时候,代码是顺序执行的. 从上往下执行. 但是我们可以控制流程的. 在控制之前,我们要先熟悉什么是语句. 相比大家学 ...
- c语言无视数据类型字符串存储,C语言基础-第二课-数据类型与运算符(示例代码)...
1 C语言中的数据类型 1.1 常量 常量就是在程序中不可变化的量,常量在定义的时候必须给一个初值. 1.1.1#define 定义一个宏常量 1.1.2const 定义一个const常量 1 ...
- 易语言html规则分析,易语言算法原理浅析【一】(示例代码)
注: 如果你看完了下面的文章.就来试试这个KeyGenMe吧,相信你能有所收获. 一.文章开头首先我们要贴上一段易语言代码,并且编译这段代码,从汇编角度分析易语言程序编译后,易语言算法在汇编中的实现过 ...
- c语言变量加常量,C语言(二)---常量与变量(示例代码)
一.进制 1.1 二进制 1.1 简介 二进制数据是用0和1两个数码来表示的数.它的基数是2,进位规则是"逢二进1",借位规则是"借一当二".当前的计算机系统使 ...
- 谁的饭量大 c语言编程,c语言第一章第一节 认识变量(示例代码)
声明:本人大一新生,闲着无聊..写写c语言教程..菜鸟一枚..大神勿喷!!! 接下来我们都用dev来进行编译..vc++太古老了,没提示功能,不好上手,并且老是出毛病..vs太大了,编个c不至于,运行 ...
- c语言 系统跑分,纯C语言跑分(详细注释)(示例代码)
#include #include//clock()所属头文件 const int N_qsort=10000;//快排的数据规模 const int M=20000,N=50000;//整点.浮点运 ...
- c语言数位重排为最大数,18.12.09-C语言练习:黑洞数 / Kaprekar问题(示例代码)
题目: 程序: 1 #include 2 3 int main(void) {4 intn, a, b, c, t, A, B;5 printf("输入一个三位数整数:");6 s ...
- hill密码源代码c语言,古典密码(Hill加密算法)(示例代码)
"Hill的加密与解密" Hill加密是另一种多字母代替密码,与多表代替密码不同的是,Hill密码要求将明文分成同等规模的若干个分组(最后一个分组涉及到填充),每一个分组被整体的加 ...
最新文章
- 【干货】105页周志华教授《机器学习手推公式》开源PDF
- linux 返回上一个文件夹_常用命令之linux指令
- 【算法】吴忠强:刷LeetCode的正确姿势!
- Salsify:高流畅度的实时视频传输新方式
- linux tcp 创建,Linux下tcp服务器创建的步骤
- 爱恨交织的编程语言 是什么吸引了你
- The setting logImpl is not known
- python 的输入 输出
- inDesign教程,如何将inDesign文档导出为 PDF 文件?
- 老男孩Linux67期第一课
- MacOS13系统升级动态壁纸无法安装解决方法
- 改变自己,永不会晚!
- 计算机科学的拉丁文,拉丁字母A-Z在计算机中对应的二进制编码
- word打开html显示空白,电脑打开Word文档内容显示不全或显示空白怎么办
- Java爬虫彼岸桌面壁纸(使用httpClient+Jsoup)
- 互联网行业职位介绍 —— OD、PM、RD、FE、UE、QA、OP、DBA...
- 3DS Max 2014启动报错的解决方案
- Python实现中英翻译
- 【电机】使用Simulink建立BLDC反电动势测量的简单模型
- CV全新范式 | LSTM在CV领域杀出一条血路,完美超越Swin与ConvNeXt等前沿算法