-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path3_2751.cpp
More file actions
74 lines (61 loc) · 1.65 KB
/
3_2751.cpp
File metadata and controls
74 lines (61 loc) · 1.65 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include <cstdio>
#include <algorithm>
using namespace std;
int result[1000000];
int N;
//void Quicksort(int start, int end);
//void swap(int x, int y);// 배열 안의 두 값의 위치 변경
int main(){
scanf("%d", &N);
for(int i=0;i<N;i++){
scanf("%d", &(result[i]));
}
sort(result, result+N);
for(int i=0;i<N;i++){
printf("%d\n", result[i]);
}
}
/*
void Quicksort(int start, int end){
int pivot = result[start];
int low = start+1;
int high = end;
while(true){
while(result[low] < pivot && low <= end) low++;
while(result[high] > pivot && high > start) high--;
if(low < high) swap(low, high);
else break;
}
swap(start, high);
if(high-1 > start) Quicksort(start, high-1);
if(end > high+1) Quicksort(high+1, end);
}
void swap(int x, int y){
int temp = result[x];
result[x] = result[y];
result[y] = temp;
}
*/
/*
void pivotsort(int start, int end){
int pivot = result[start];
int small_count=0;// pivot보다 작은 값들의 개수
for(int i=start+1;i<end+1;i++){
if(result[i] < pivot){
temp[start+small_count] = result[i];
small_count++;
}
}
temp[start+small_count] = pivot;
int large_count=0;// pivot값보다 큰 값들의 개수
for(int i=start+1;i<end+1;i++){
if(result[i] > pivot){
temp[start+small_count+large_count+1] = result[i];
large_count++;
}
}
for(int i=0;i<N;i++) result[i] = temp[i];
if(small_count > 1) pivotsort(start, start+small_count);
if(large_count > 1) pivotsort(start+small_count+2, end);
}
*/