문제 링크입니다: https://www.acmicpc.net/problem/4493
4493번: 가위 바위 보?
첫째 줄에는 테스트 케이스의 개수 t(0 < t < 1000)가 주어진다. 각 테스트 케이스의 첫째 줄에는 가위 바위 보를 한 횟수 n(0 < n < 100)이 주어진다. 다음 n개의 줄에는 R, P, S가 공백으로 구분되어 주어
www.acmicpc.net
간단한 구현 문제였습니다.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
int main(void) | |
{ | |
ios_base::sync_with_stdio(0); | |
cin.tie(0); | |
int T; | |
cin >> T; | |
for (int t = 0;t < T; t++) | |
{ | |
int n; | |
cin >> n; | |
int player1 = 0, player2 = 0; | |
for (int i = 0; i < n; i++) | |
{ | |
char a, b; | |
cin >> a >> b; | |
switch (a) | |
{ | |
case 'R': | |
if (b == 'R') | |
{ | |
player1++; | |
player2++; | |
} | |
else if (b == 'P') | |
{ | |
player2++; | |
} | |
else | |
{ | |
player1++; | |
} | |
break; | |
case 'P': | |
if (b == 'R') | |
{ | |
player1++; | |
} | |
else if (b == 'P') | |
{ | |
player1++; | |
player2++; | |
} | |
else | |
{ | |
player2++; | |
} | |
break; | |
case 'S': | |
if (b == 'R') | |
{ | |
player2++; | |
} | |
else if (b == 'P') | |
{ | |
player1++; | |
} | |
else | |
{ | |
player1++; | |
player2++; | |
} | |
break; | |
} | |
} | |
if (player1 > player2) | |
{ | |
cout << "Player 1\n"; | |
} | |
else if (player1 == player2) | |
{ | |
cout << "TIE\n"; | |
} | |
else | |
{ | |
cout << "Player 2\n"; | |
} | |
} | |
return 0; | |
} |


개발환경:Visual Studio 2017
지적, 조언, 질문 환영입니다! 댓글 남겨주세요~
반응형
'알고리즘 > BOJ' 카테고리의 다른 글
백준 4619번 루트 (0) | 2021.05.15 |
---|---|
백준 4504번 배수 찾기 (0) | 2021.05.15 |
백준 4388번 받아올림 (0) | 2021.05.15 |
백준 4153번 직각삼각형 (0) | 2021.05.15 |
백준 4101번 크냐? (0) | 2021.05.15 |