Phạm Trần Minh Hiếu
@2280600972
Code để tham khảo nè
include <stdio.h>
include <stdlib.h>
int compare(const void * a,
const void * b) {
return ( * (int * ) a - * (int * ) b);
}
void bai1331() {
int n;
if (scanf("%d", & n) != 1) return;
int a[100];
for (int i = 0; i < n; i++) {
scanf("%d", & a[i]);
}
qsort(a, n, sizeof(int), compare);
for (int i = 0; i < n; i++) {
printf("%d%c", a[i], (i == n - 1) ? '\n' : ' ');
}
for (int i = n - 1; i >= 0; i--) {
printf("%d%c", a[i], (i == 0) ? '\n' : ' ');
}
}
int main() {
bai1331();
return 0;
}
Trả lời
0 Phản hồi
Bạn cần đăng nhập để tham gia thảo luận
Đăng nhập ngay