電腦學院大學生程式設計競賽(2015’12)The Magic Tower

來源:互聯網
上載者:User
The Magic Tower Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2382    Accepted Submission(s): 615


Problem Description Like most of the RPG (role play game), “The Magic Tower” is a game about how a warrior saves the princess. 
After killing lots of monsters, the warrior has climbed up the top of the magic tower. There is a boss in front of him. The warrior must kill the boss to save the princess.
Now, the warrior wants you to tell him if he can save the princess.  
Input There are several test cases.
For each case, the first line is a character, “W” or “B”, indicating that who begins to attack first, ”W” for warrior and ”B” for boss. They attack each other in turn. 
The second line contains three integers, W_HP, W_ATK and W_DEF. (1<=W_HP<=10000, 0<=W_ATK, W_DEF<=65535), indicating warrior’s life point, attack value and defense value. 
The third line contains three integers, B_HP, B_ATK and B_DEF. (1<=B_HP<=10000, 0<=B_ATK, B_DEF<=65535), indicating boss’s life point, attack value and defense value. 

Note: warrior can make a damage of (W_ATK-B_DEF) to boss if (W_ATK-B_DEF) bigger than zero, otherwise no damage. Also, boss can make a damage of (B_ATK-W_DEF) to warrior if (B_ATK-W_DEF) bigger than zero, otherwise no damage. 
 
Output For each case, if boss’s HP first turns to be smaller or equal than zero, please print ”Warrior wins”. Otherwise, please print “Warrior loses”. If warrior cannot kill the boss forever, please also print ”Warrior loses”.
 
Sample Input
 W 100 1000 900 100 1000 900 B 100 1000 900 100 1000 900   

Sample Output
 Warrior wins Warrior loses   

總是望著曾經的空間發獃,那些說好不分開的朋友不在了,轉身,陌路。 熟悉的,安靜了, 安靜的,離開了, 離開的,陌生了, 陌生的,消失了, 消失的,陌路了。

#include <stdio.h>#include <stdlib.h>int main(){    char a;    int i,W_HP,W_ATK,W_DEF,B_HP,B_ATK,B_DEF,w_b,b_w;    while(~scanf("%c",&a))    {        scanf("%d%d%d%d%d%d%*c",&W_HP,&W_ATK,&W_DEF,&B_HP,&B_ATK,&B_DEF);        w_b=W_ATK-B_DEF;        //w對b每一次攻擊的數值        if(w_b<0) w_b=0;        b_w=B_ATK-W_DEF;        //b對w每一次攻擊的數值        if(b_w<0) b_w=0;        if(a=='W')        {            for(i=1;i>=1;i++)            {                if(w_b==0)                {                    printf("Warrior loses\n");                    break;                }                B_HP-=w_b;                if(B_HP<0)                {                    printf("Warrior wins\n");                    break;                }                W_HP-=b_w;                if(W_HP<0)                {                    printf("Warrior loses\n");                    break;                }            }        }        if(a=='B')        {            for(i=1;i>=1;i++)            {                if(w_b==0)                {                    printf("Warrior loses\n");                    break;                }                W_HP-=b_w;                if(W_HP<0)                {                    printf("Warrior loses\n");                    break;                }                B_HP-=w_b;                if(B_HP<0)                {                    printf("Warrior wins\n");                    break;                }            }        }    }    return 0;}

@執念  "@☆但求“”安★ 下次我們做的一定會更好。。。。
為什麼這次的題目是英文的。。。。QAQ...

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.