Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ConsoleApplication3.cpp : main project file.
- #include "stdafx.h"
- #include <conio.h>
- #include <iostream>
- using namespace std;
- using namespace System;
- int main()
- {
- int n;
- cin >> n;
- int aux = 0;
- int *a = new int[n];
- for (int i = 0; i < n; i++)
- {
- cout << "Ingrese un numero: " << endl;
- cin >> a[i];
- }
- for (int i = 0; i < n - 1; i++)
- {
- for (int j=i+1; j<n; j++)
- if (a[i] > a[j])
- {
- aux = a[i];
- a[i] = a[j];
- a[j] = aux;
- }
- }
- for (int i = 0; i < n; i++)
- {
- cout << a[i]<<' ';
- }
- _getch();
- return 0;
- }
Add Comment
Please, Sign In to add comment