Counting sheep (four brushes) kkmd66

The Pleasant version of Quidditch is being held on Berk Island, where people and dragons live in harmony (Quidditch is the Chinese translation of Quidditch, an important aerial team confrontation sport in the Harry Potter series. (a ball game with broomsticks), the Dragon Knights score points by catching sheep and throwing them into the basket. If they can catch the dark-skinned boiling sheep, they can get extra points.

Now there are five kinds of sheep: Xiyangyang, Meiyang, Boiling, Lazy and Slow. Representing the score: 5 points, 8 points, 10 points, 15 points, 20 points. However, if the number of sheep caught by a team is greater than or equal to 10, and there is a boiled sheep, the team's score will be increased by 50.

As young and heroic Viking warrior Hiccup, you didn't play this game, but can you help your Girl Friend Astrid count how many points their team has scored?

#include <iostream>
#include "string"

using namespace std;

/**
 * kkmd66 四刷
 * @param str
 * @return
 */

int score(const string &str) {
    
    
    if (str == "Pleasant")
        return 5;
    if (str == "Pretty")
        return 8;
    if (str == "Athletic")
        return 10;
    if (str == "Lazy")
        return 15;
    if (str == "Slow")
        return 20;
}

/**
 * kkmd66 四刷
 * @return
 */

int main() {
    
    

    int n,count=0;
    while (cin >> n) {
    
    
        //计次
        count++;

        //计分
        int sum = 0;
        //是否有沸羊羊
        bool flag = false;

        for (int i = 0; i < n; ++i) {
    
    
            string str,temp;
            cin>>str>>temp;
            if (str == "Athletic")
                flag = true;
            sum += score(str);
        }

        if (flag && n >= 10)
            cout <<"Case #"<<count<<": "<< sum + 50 << endl;
        else
            cout <<"Case #"<<count<<": "<< sum << endl;
    }
    
    return 0;
}

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=324119427&siteId=291194637