fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. void swap(int *a,int *b)
  5. {
  6. int t;
  7. t=*a;
  8. *a=*b;
  9. *b=t;
  10. }
  11. int main() {
  12. // your code goes here
  13. int a[]={4,6,1,8,5,9};
  14.  
  15. int n=sizeof(a)/sizeof(a[0]);
  16.  
  17. for(int i=0;i<n-1;i++)
  18. {
  19. for(int j=i+1;j<n;j++)
  20. {
  21. if(a[i]<a[j])
  22. swap(&a[i],&a[j]);
  23. }
  24. }
  25.  
  26. for(int i=0;i<n;i++)
  27. cout<<a[i]<<" ";
  28. return 0;
  29. }
Success #stdin #stdout 0s 4864KB
stdin
Standard input is empty
stdout
9 8 6 5 4 1