Xavistian

Untitled

May 30th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.56 KB | None | 0 0
  1. // ConsoleApplication3.cpp : main project file.
  2.  
  3. #include "stdafx.h"
  4. #include <conio.h>
  5. #include <iostream>
  6. using namespace std;
  7. using namespace System;
  8.  
  9. int main()
  10. {
  11.     int n;
  12.     cin >> n;
  13.     int aux = 0;
  14.     int *a = new int[n];
  15.     for (int i = 0; i < n; i++)
  16.     {
  17.         cout << "Ingrese un numero: " << endl;
  18.         cin >> a[i];
  19.     }
  20.     for (int i = 0; i < n - 1; i++)
  21.     {
  22.         for (int j=i+1; j<n; j++)
  23.             if (a[i] > a[j])
  24.             {
  25.                 aux = a[i];
  26.                 a[i] = a[j];
  27.                 a[j] = aux;
  28.             }
  29.     }
  30.     for (int i = 0; i < n; i++)
  31.     {
  32.         cout << a[i]<<' ';
  33.     }
  34.     _getch();
  35.     return 0;
  36. }
Add Comment
Please, Sign In to add comment