#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <windows.h>
#include <unistd.h>
void show()
{
srand(time(NULL));
printf("随机数字:%d\n",rand());
int hp1 = 100,hp2 = 100;
int att1,att2;
int i = 0;
while (hp1 >= 0 && hp2 >= 0)
{
att1 = rand() % 11 + 5;
att2 = rand() % 11 + 5;
hp2 -= att1;
hp1 -= att2;
printf("************************************************************************\n");
if(att1 <= 8)
{
printf("张二狗一发鬼影鞭对王三胖造成%d点伤害,王三胖对他竖起中指\n,此时二人血量:张二狗%d\t王三胖%d\n",att1,hp1,hp2);
}
else if(att1>8 && att1<=12)
{
printf("张二狗吃下一口热翔对王三胖使出一招'飙屎墓碑'对王三胖造成%d点伤害,王三胖不由皱起眉头\n此时二人血量:张二狗%d\t王三胖%d\n",att1,hp1,hp2);
}
else if(att1 >12)
{
printf("张二狗灵光一闪,一招崩山裂地斩下去,王三胖受到%d点伤害吐血三缸\n此时二人血量:张二狗%d\t王三胖%d\n",att1,hp1,hp2);
}
if(att2 <= 8)
{
printf("王三胖怒了,掏出十米长的大刀对着张二狗当头砍下,张二狗头上飘起了一行红字:'hp-%d'\n,此时二人血量:张二狗%d\t王三胖%d\n",att2,hp1,hp2);
}
else if(att2>8 && att2<=12)
{
printf("王三胖觉得是时候放个大招了,只见他双手合十口中隐约念起了咒语'妈咪妈咪哄',张二狗顿时觉得菊花一紧,hp-%d\n此时二人血量:张二狗%d\t王三胖%d\n",att2,hp1,hp2);
}
else if(att2 > 12)
{
printf("王三胖朝天吼了三声'哈哈哈',紧接着使出了传说中的剑帝大招'飞花逐月'把张二狗打的屁股尿流,hp-%d\n此时二人血量:张二狗%d\t王三胖%d\n",att2,hp1,hp2);
}
i++;
Sleep(2000);
}
if(hp1 > hp2)
{
printf("皇城PK结束,吃翔君主--张二狗获得胜利,爸爸奖励他一缸咖喱味老虎翔\n");
}
else
{
printf("皇城PK结束,井盖剑帝--王三胖获得胜利,爸爸奖励他一缸老虎翔味咖喱\n");
}
return;
}
int main()
{
show();
return 0;
}
皇城PK--循环的简单运用
最新推荐文章于 2021-05-25 16:50:48 发布