```
백준 20499번 K/D/A 점수변환 C++ 구현해보기
```

이번 글을 통해 배워갈 내용
- 백준 20499번 풀이
https://www.acmicpc.net/problem/20499
20499번: Darius님 한타 안 함?
그가 「진짜」이면 gosu, 「가짜」이면 hasu를 출력한다.
www.acmicpc.net
백준 20499번 Darius님 한타 안 함? (K/D/A 점수변환)은
난이도 브론즈 등급의 문제로서
게임을 할때 Kill, Death, Assist 점수가 주어질때
D 가 0 이거나
K + A < D 이면
"hasu"
그외의 경우
"gosu"를 출력하면 되는 문제다.
여기서 특별한 점은
입력이
0/5/3 이런식으로
/로 구분되서 된다는 점이다.
30분 정도 위에 링크를 방문하셔서 풀어보시고
안풀리시는 경우에만 아래 해답을 봐주시면 감사하겠습니다.
regex를 이용해서
입력에서 "/"을 " "변환해주고
streamstream으로 값을 받아서
계산해주고
판별하면되는 매우 간단한 문제입니다.
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <array>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <regex>
std::string gCommonStr;
std::string gNthStr;
int main()
{
std::cin.tie(NULL);
std::ios::sync_with_stdio(false);
std::string inputStr;
std::getline(std::cin, inputStr);
inputStr = std::regex_replace(inputStr, std::regex("/"), " ");
std::stringstream ss(inputStr);
int32_t K;
ss >> K;
int32_t D;
ss >> D;
int32_t A;
ss >> A;
std::string outputStr;
if ((D == 0) || ((K + A)< D))
{
outputStr = "hasu";
}
else
{
outputStr = "gosu";
}
std::cout << outputStr;
}
읽어주셔서 감사합니다
무엇인가 얻어가셨기를 바라며
오늘도 즐거운 코딩하시길 바랍니다 ~ :)
참조 및 인용
C++ Primer
Introduction to Algorithms
https://codemasterkimc.tistory.com/35
C++ 이론을 배울수 있는 곳 정리
개요 C++을 배우는 책, 강의, 블로그, 링크 등을 공유합니다. (링크 및 간략한 설명을 하였으나 만약 원작자가 링크를 거는것을 원치 않을 경우 연락주시기 바랍니다.) 서적 https://www.amazon.com/Prime
codemasterkimc.tistory.com
https://codemasterkimc.tistory.com/50
300년차 개발자의 좋은 코드 5계명 (Clean Code)
이번 글을 통해 배워갈 내용 좋은 코드(Clean Code)를 작성하기 위해 개발자로서 생각해볼 5가지 요소를 알아보겠습니다. 개요 좋은 코드란 무엇일까요? 저는 자원이 한정적인 컴퓨터 세상에서 좋
codemasterkimc.tistory.com
'C++ > C++ 알고리즘' 카테고리의 다른 글
| 백준 15894번 수학은체육과목입니다. C++ 구현해보기 (0) | 2021.09.18 |
|---|---|
| 백준 23037번 5자리 각 숫자 5제곱 해서 더하기 (0) | 2021.09.12 |
| 백준 3107번 IPv6 변환 C++ 구현해보기 (0) | 2021.09.12 |
| 백준 2718번 4 X N 타일 채우기 C++ 구현해보기 (0) | 2021.09.11 |
| 백준 11727번 2xn 타일링2 C++ 구현해보기 (0) | 2021.09.11 |