#include<iostream>
using namespace std;
void mergeAsc(double num[],int left,int mid,int right) { double tmp[right-left+1]; int p1=left,p2=mid+1,index=0; while(p1<=mid&&p2<=right) { if(num[p1]<num[p2]) { tmp[index]=num[p1]; p1++; index++; } else { tmp[index]=num[p2]; p2++; index++; } }
while(p1<=mid) { tmp[index]=num[p1]; p1++; index++; }
while(p2<=right) { tmp[index]=num[p2]; p2++; index++; }
for(int i=0;i<right-left+1;i++) num[left+i]=tmp[i]; }
void MergeSortAsc(double num[],int left,int right) { if(left>=right) return; int mid=(left+right)/2; MergeSortAsc(num,left,mid); MergeSortAsc(num,mid+1,right); mergeAsc(num,left,mid,right); }
void mergeDesc(double num[],int left,int mid,int right) { double tmp[right-left+1]; int p1=left,p2=mid+1,index=0; while(p1<=mid&&p2<=right) tmp[index++]=num[p1]>num[p2]?num[p1++]:num[p2++]; while(p1<=mid) tmp[index++]=num[p1++]; while(p2<=right) tmp[index++]=num[p2++]; for(int i=0;i<right-left+1;i++) num[left+i]=tmp[i]; }
void MergeSortDesc(double num[],int left,int right) { if(left>=right) return; int mid=(left+right)/2; MergeSortDesc(num,left,mid); MergeSortDesc(num,mid+1,right); mergeDesc(num,left,mid,right); }
int main() { double num[1000]; int length; for(length=0;cin>>num[length];length++); MergeSortDesc(num,0,length-1); for(int i=0;i<length;i++) cout<<num[i]<<" "; return 0; }
|