Skip to content

Instantly share code, notes, and snippets.

@LisGein
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LisGein/acac732e80e9019c6d30 to your computer and use it in GitHub Desktop.
Save LisGein/acac732e80e9019c6d30 to your computer and use it in GitHub Desktop.
#include <iostream>
using namespace std;
int main()
{
int n;
cout << "Enter n" << endl;
cin >> n;
int *arr = new int[n];
int i = 0;
for (i = 0; i < n; i++)
{
cout << "Vvedite massiv" << endl;
cin >> arr[i];
}
int j;
int d;
for (int i = 0; i<n; i++)
{
for (int j = 0; j < n - 1; j++)
{
if (arr[j] > arr[j + 1])
{
int d = arr[j];
arr[j] = arr[j + 1];
arr[j + 1] = d;
}
}
}
int *a = new int[n];
for (int i = 0; i < n; i++)
a[i] = arr[i];
for (int i = 0; i < n; ++i)
cout << "[" << i+1 << "] " << arr[i] << "" << endl;
delete [] arr;
system("pause");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment