zoukankan      html  css  js  c++  java
  • 计算机学院大学生程序设计竞赛(2015’12) 1009 The Magic Tower

    #include<cmath>
    #include<cstdio>
    #include<cstring>
    #include<algorithm>
    using namespace std;
    
    int whp,wat,wdef,bhp,bat,bdef;
    char s;
        
    int main()
    {
        while(~scanf("%c",&s))
        {
            scanf("%d%d%d",&whp,&wat,&wdef);
            scanf("%d%d%d",&bhp,&bat,&bdef);
            int t1=wat-bdef;
            int t2=bat-wdef;
    
            if(s=='W')
            {
                while(1)
                {
                    if(t1>0) bhp-=t1;
                    if(bhp<=0)
                    {
                        printf("Warrior wins
    ");
                        break;
                    }
    
                    if(t2>0) whp-=t2;
                    if(whp<=0)
                    {
                        printf("Warrior loses
    ");
                        break;
                    }
    
                    if(t1<=0)
                    {
                        printf("Warrior loses
    ");
                        break;
                    }
                }
            }
            else if(s=='B')
            {
                while(1)
                {
                    if(t2>0) whp-=t2;
                    if(whp<=0)
                    {
                        printf("Warrior loses
    ");
                        break;
                    }
    
                    if(t1>0) bhp-=t1;
                    if(bhp<=0)
                    {
                        printf("Warrior wins
    ");
                        break;
                    }
    
                    if(t1<=0)
                    {
                        printf("Warrior loses
    ");
                        break;
                    }
                }
            }
        }
        return 0;
    }
  • 相关阅读:
    抽象工厂
    组合和继承
    Mysql 设置远程连接
    websocket
    redis 持久化
    django urls
    git gitignore
    Mysql 系统表
    cudnn升级之后caffe无法训练的问题
    python numpy初始化一个图像矩阵
  • 原文地址:https://www.cnblogs.com/zufezzt/p/5080479.html
Copyright © 2011-2022 走看看