Computer College Undergraduate Program Design Contest (2015 ') the Magic Tower

Source: Internet
Author: 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-playing play game), "The Magic Tower" are a game about how a warrior saves the Princ Ess.
After killing lots of monsters, the warrior has climbed to 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 for you and him if he can save the princess.
Input There are several test cases.
For each case, the the ' the ' a character, ' W ' or ' B ', indicating, who begins to attack, ' W ' for Warrior and "B" for boss. They attack each of the other in turn.
The second line contains three integers, w_hp, w_atk and W_def. (1<=w_hp<=10000, 0&LT;=W_ATK, w_def<=65535), Indi Cating 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&LT;=B_ATK, b_def<=65535), Indic Ating 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-a-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 1000 900 1000 900 B 100 1000 900 100 1000 900
Sample Output
Warrior wins Warrior loses

always looking at once space in a daze, those who say not separate friends, turn around, strangers. Familiar, quiet, quiet, left, left, unfamiliar, unfamiliar, disappeared, disappeared, strangers.

#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,&amp ;
        B_DEF);        W_b=w_atk-b_def;
        W to b The value of each attack if (w_b<0) w_b=0;        B_w=b_atk-w_def;
        B to w each attack value 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;
 }

@ hold read "@☆ but beg" ❤ "Ann ★ Next time we do will be better ....
for what this time the topic is in English .... Qaq ...

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.