皇城PK--循环的简单运用

#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;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值