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 | #pragma warning (disable:4996) #include <stdio.h> #include <stdlib.h> void sort(int* num, int size) { int temp = 0; for (int i = 0; i < size; i++) { for (int j = i; j < size; j++) { if (num[i] < num[j]) { temp = num[i]; num[i] = num[j]; num[j] = temp; } } } } int main() { int size; scanf("%d", &size); int* num = (int*)malloc(sizeof(int) * size); for (int i = 0; i < size; i++) scanf("%d", &num[i]); sort(num, size); for (int i = 0; i < size; i++) printf("%d ", num[i]); return 0; } | cs |
프로그래밍 문제/정올