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
|
# include <stdio.h>
void bubble_sort(int list[], int n)
{
int temp = 0;
for (int i = 0; i < n; i++)
{
for (int j = 0; j < n - i - 1; j++)
{
if (list[j] > list[j + 1])
{
temp = list[j];
list[j] = list[j + 1];
list[j + 1] = temp;
}
}
}
}
int main()
{
int num[3] = { 0, };
for (int idx = 0; idx < 3; idx++)
{
scanf("%d", &num[idx]);
}
bubble_sort(num, 3);
printf("%d\n", num[1]);
return 0;
}
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
|
http://colorscripter.com/info#e" target="_blank" style="text-decoration:none;color:white">cs |
참고 자료-
버블소팅을 이용.
출처: https://ilove-ns-moka.tistory.com/26?category=701066 [오늘하루도 수고했다링]
버블소팅
내림차순으로 정렬하실경우 예제의 IF문의 부등호방향만 바꿔주시면 됩니다. 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 # include # define MAX_..
ilove-ns-moka.tistory.com
백준 컴파일 에러.
https://www.acmicpc.net/blog/view/52
컴파일 에러가 나시나요? (C/C++)
최근들어 컴파일에러로 오답을 받고 질문을 올리시는 분이 자주 보이는 것 같습니다. 주로 그 내용은 "비주얼 스튜디오에서는 되는 데 백준에서는 오류가 나네요" 등이더군요. 컴파일 에러를 해결하시는 데에 도움이 될 만한 글을 남기고자 합니다. 비쥬얼 스튜디오에서는 되는 데.. 비쥬얼 스튜디오는 생각 이상으로 강력한 통합 개발 환경(IDE)을 제공합니다. 아래 코드는 컴파일 에러일까요? #include int main() { printf("%d", strlen
www.acmicpc.net
scanf_s 사용 오류 날때.
'프로그래밍 > 알고리즘' 카테고리의 다른 글
백준 10951 (0) | 2019.08.26 |
---|---|
별찍기 (0) | 2019.08.22 |
버블소팅 (0) | 2019.08.21 |
백준 2884 알람 시계 (0) | 2019.08.20 |
백준 2753 윤년 (0) | 2019.08.20 |