(백준) 18408 – つの整数 (Three Integers) (C++)

쉬운 목차

문제

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

설명

3개의 정수를 받아 1이 더 있는지 2가 더 있는지를 출력하는 문제입니다.


count 함수를 사용하기 위해 입력을 벡터로 취했습니다.

#include <iostream>
#include <regex>
using namespace std;

int main() {
    vector<int> v(3);
    for (int i = 0; i < 3; i++) {
        cin >> v(i);
    }
  
    int one = count(v.begin(), v.end(), 1);
    int two = count(v.begin(), v.end(), 2);
    
    if (one > two) {
      cout << "1";
    }
    else {
      cout << "2";
    }
    
    return 0;
}