본문 바로가기

Algorithm/Implementation

(C++) - 백준(BOJ) 9947번 : Coin tossing

반응형

https://www.acmicpc.net/problem/9947

 

9947번: Coin tossing

When I was at school, many, many years ago, we used to play a simple game involving tossing a coin. The first player would call "heads" or "tails", the second would toss the coin. The first player gained a point for every correct call, the second player ga

www.acmicpc.net

단순 구현 문제였습니다.

 

 

📕 Code

#include <bits/stdc++.h>
using namespace std;
string a,b;
int aScore, bScore, n;
int main(){
    while(1){
        cin >> a >> b;
        if(a == "#" && b == "#" ) break;

        cin >> n;
        aScore = bScore = 0;

        while(n--){
            char c1,c2;
            cin >> c1 >> c2;
            if(c1 == c2) aScore++;
            else bScore++;
        }
        
        cout << a << ' ' << aScore << ' ' << b << ' ' << bScore << '\n';
    }
}