Advertisement
gosuodin

SORT A>Z

Jun 6th, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3.  
  4.  
  5. int main()
  6. {
  7. int n;
  8. cout << "nhap n :";
  9. cin >> n;
  10. int *a = new int[n];
  11. for (int i = 0; i < n; i++) {
  12. cout << "nhap a[" << i + 1 << "]";
  13. cin >> a[i];
  14. }
  15. for (int i = 0; i < n; i++) {
  16. for (int j = 0; j < n; j++) {
  17. if (a[i] > a[j]) {
  18. int luu = a[i];
  19. a[j] = a[i];
  20. a[i] = luu;
  21. cout << a[j];
  22. }
  23. }
  24. }
  25.  
  26. system("pause");
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement