Advertisement
Guest User

braduraz

a guest
Apr 27th, 2015
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. #include<iostream.h>
  2. int main()
  3. {
  4. int i,j,n,a[20],aux;
  5. cout<<"n=", cin>>n;
  6. for(i=1;i<=n;i++)
  7. {
  8. cout<<"a["<<i<<"]=";
  9. cin>>a[i];
  10. }
  11. for(i=1;i<=n-1;i++)
  12. for(j=i+1;j<=n;j++)
  13. if(a[i]>a[j])
  14. {
  15. aux=a[i];
  16. a[i]=a[j];
  17. a[j]=aux;
  18. }
  19. cout<<"sirul ordonat este:"<<endl;
  20. for(i=1;i<=n;i++)
  21. cout<<a[i]<<" ";
  22. cout<<endl;
  23. return(0);
  24.  
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement