Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- 정석학술정보관
- 컴퓨터공학과
- Stack
- 문제풀이
- Operating System
- 자료구조
- 컴공
- vector
- 스택
- 오퍼레이팅시스템
- coding
- 브루트포스
- 구현
- 그래프
- 북리뷰
- 너비우선탐색
- 컴공과
- 백준
- cs
- 정석
- 알고리즘
- Computer science
- OS
- 코딩
- c++
- 오에스
- DP
- 코테
- 개발
- bfs
Archives
- Today
- Total
Little Jay
[C++] 백준 2693번 N번째 큰 수 본문
벡터로 풀기
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
int testCase;
cin >> testCase;
vector<int> arr;
int input;
for (int i = 0; i < testCase; i++) {
for (int k = 0; k < 10; k++) {
cin >> input;
arr.push_back(input);
}
sort(arr.begin(), arr.end());
cout << arr[7] << "\n";
arr.clear();
}
return 0;
}
배열로 풀기
#include <iostream>
#include <array>
#include <algorithm>
using namespace std;
int main() {
int a;
cin >> a;
int N = 7;
for (int i = 0; i < a; i++) {
int ary[10];
for (int k = 0; k < 10; k++) {
cin >> ary[k];
}
sort(ary, ary + 10);
cout << ary[N] << "\n";
}
return 0;
}
두개의 방법 다 메모리 사용하는 것은 똑같다
'알고리즘 > BOJ' 카테고리의 다른 글
[C++] 백준 1267번 핸드폰 요금 (0) | 2021.02.28 |
---|---|
[C++] 백준 2747번 피보나치 수 (0) | 2021.02.28 |
[C++] 백준 3507번 Automated Telephone Exchange (0) | 2021.02.27 |
[C++] 백준 18108번 1998년생인 내가 태국에서는 2541년생?! (0) | 2021.02.27 |
[C++] 백준 2743번 단어 길이 재기 (0) | 2021.02.27 |
Comments