본문 바로가기
C/중간고사 대비 (2022 1학기)

[C 백준] 실버 5/ 2693 N번째 큰 수

by Meaning_ 2022. 4. 8.
728x90
반응형
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#define _CRT_SECURE_NO_WARNINGS
#pragma warning(disable: 4996)
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
 
 
 
int a[1001][11];
int main() {
 
    int t;
    scanf("%d"&t);
    
    int cnt = 0;
    while (cnt != t) {
        for (int i = 0; i < 10; i++) {
            int num;
            scanf("%d"&num);
            a[cnt][i] = num;
        }
        
 
        cnt++;
    }
    
 
    cnt = 0;
    while (cnt != t) {
        for (int i = 0; i < 10; i++) {
            for (int j = 0; j < 10; j++) {
                if (a[cnt][i] > a[cnt][j]) {
                    int temp = a[cnt][i];
                    a[cnt][i] = a[cnt][j];
                    a[cnt][j] = temp;
                }
            }
        }
 
        cnt++;
 
    }
 
    for (int i = 0; i < t; i++) {
        printf("%d\n", a[i][2]);
    }
 
}
 
cs

소트 인사이드와 결이 비슷한 문제이다. 버블정렬하면 되는!

아니 근데 C언어는 내장함수가 없어서 하나하나 다 만들어야 한다니 정말 끔찍하다. 

오늘 다른 실버4 난도의 문제들도 좀 찾아봤는데 comparator나 find함수가 없어서 뭐 하질 못했다.

그냥 내 역량부족인가보다 ㅋㅋㅋ 설마 중간에 나오진 않겠지,,,??

728x90
반응형

댓글