문제 링크입니다: www.acmicpc.net/problem/13985
13985번: Equality
Print, on a single line, YES if the sum is correct; otherwise, print NO.
www.acmicpc.net
간단한 구현 문제였습니다.
This file contains hidden or 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> | |
#include <string> | |
using namespace std; | |
const int FIRST_NUM_IDX = 0; | |
const int SECOND_NUM_IDX = 4; | |
const int RESULT_IDX = 8; | |
int main(void) | |
{ | |
ios_base::sync_with_stdio(0); | |
cin.tie(0); | |
string input; | |
getline(cin, input); | |
int firstNum = input[FIRST_NUM_IDX] - '0'; | |
int secondNum = input[SECOND_NUM_IDX] - '0'; | |
int result = input[RESULT_IDX] - '0'; | |
if (firstNum + secondNum == result) | |
{ | |
cout << "YES\n"; | |
} | |
else | |
{ | |
cout << "NO\n"; | |
} | |
return 0; | |
} |


개발환경:Visual Studio 2017
지적, 조언, 질문 환영입니다! 댓글 남겨주세요~
반응형
'알고리즘 > BOJ' 카테고리의 다른 글
백준 14065번 Gorivo (0) | 2021.03.16 |
---|---|
백준 14038번 Tournament Selection (0) | 2021.03.16 |
백준 13866번 팀 나누기 (0) | 2021.03.16 |
백준 13610번 Volta (2) | 2021.03.15 |
백준 13597번 Tri-du (0) | 2021.03.15 |