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

문제 분석

입력된 숫자들을 비내림차순으로 정렬하여 출력하는 문제입니다.

비내림차순하고 오름차순이랑 뭐가다른진 모르겠네요. 

vector로 받은 다음에 sort 로 정렬해서 오름차순으로 출력해서 풀었습니다.

 

소스 코드

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
using std::cin;
using std::cout;

int main()
{ 
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	cin >> n;
	vector<int> v(n);
	for (int i = 0; i < n; i++)
	{
		int k;
		cin >> k;
		v[i] = k;
	}
	sort(v.begin(), v.end());
	for (auto a : v)
	{
		cout << a << "\n";
	}
}

 

'백준 > 실버' 카테고리의 다른 글

[백준 1622]- 공통 순열(c++)  (0) 2026.04.03
[백준 15729]- 방탈출(c++)  (0) 2026.03.25
[백준 3060]- 욕심쟁이 돼지(c++)  (0) 2026.03.23
[백준 14916] - 거스름돈(c++)  (0) 2026.03.16
[백준 1340] - 연도 진행바  (0) 2026.03.05

+ Recent posts