baru003のブログ

baruの雑記兼備忘録

AOJ 0103

・問題リンク Baseball Simulation

・コメント
ウェブで参考にさせて頂きました。
ポイントはヒットはシングルヒットのみだということでした。

・ソース

#include<iostream>
#include<string>
using namespace std;

int main()
{
    int n;
    cin>>n;
    while(n--!=0){
        int runner=0;
        int count=0;
        int out=0;
        string j;
        while(out<3){
            cin>>j;
            if(j=="HIT"){
                if(runner<3){
                    runner++;
                }
                else{
                    count++;
                }
            }
            else if(j=="HOMERUN"){
                count+=runner+1;
                runner=0;
            }
            else{
                out++;
            }
        }
        cout<<count<<endl;
    }
    return 0;
}