[C++][백준 2752] 세수정렬

PublicMinsu·2025년 8월 23일

문제

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

접근 방법

직접 비교하여서 가장 큰 수, 가장 작은 수, 무엇에도 해당되지 않는 수를 찾아내거나 정렬해 주는 함수를 활용하면 됩니다.

코드

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

int nums[3];

int main()
{
    ios::sync_with_stdio(0), cin.tie(0);

    for (int &num : nums)
    {
        cin >> num;
    }

    sort(nums, nums + 3);

    for (const int &num : nums)
    {
        cout << num << " ";
    }

    return 0;
}

풀이

크기가 3인 배열을 만든 뒤 입력을 받아주고 sort로 정렬해 주었습니다.

profile
연락 : publicminsu@naver.com

0개의 댓글