#include <iostream> #include <algorithm> using namespace std; #define MAX 1001 int a[MAX]; typedef struct LinkNode{ int val; LinkNode *next; }*LinkList, LinkNode; int main() { int n; cin>>n; int i = 0; while (cin >> a[i++]) { } LinkNode *Head = new LinkNode; Head->next = nullptr; sort(a, a + n, greater<int>()); for(i = 0; i < n; i ++){ LinkNode *L= new LinkNode; L->val = a[i]; L->next = Head->next; Head->next = L; } LinkNode *temp = new LinkNode; temp = Head->next; while(temp){ cout<<temp->val<<' '; temp = temp -> next; } free(temp); }