알고리즘/BOJ

백준 18408번 3 つの整数

꾸준함. 2021. 3. 27. 02:32

문제 링크입니다: www.acmicpc.net/problem/18408

 

18408번: 3 つの整数

3 つの整数 A, B, C が与えられる.A, B, C はそれぞれ 1 または 2 である.1 と 2 のうち,どちらが多くあるか.

www.acmicpc.net

간단한 구현 문제였습니다.

 

#include <iostream>
using namespace std;
const int MAX = 3;
int main(void)
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int oneCnt = 0, twoCnt = 0;
for (int i = 0; i < MAX; i++)
{
int num;
cin >> num;
num == 1 ? oneCnt++ : twoCnt++;
}
cout << (oneCnt > twoCnt ? "1\n" : "2\n");
return 0;
}
view raw ,cpp hosted with ❤ by GitHub

 

개발환경:Visual Studio 2017

 

지적, 조언, 질문 환영입니다! 댓글 남겨주세요~

반응형

'알고리즘 > BOJ' 카테고리의 다른 글

백준 18414번 X に最も近い値  (0) 2021.03.27
백준 18411번 試験  (0) 2021.03.27
백준 18330번 Petrol  (0) 2021.03.27
백준 18005번 Even or Odd?  (0) 2021.03.27
백준 17903번 Counting Clauses  (0) 2021.03.26