Skip to content

Instantly share code, notes, and snippets.

@saginadir
Created May 11, 2017 11:45
Show Gist options
  • Save saginadir/adff59de7d24fc4ac201941538df492b to your computer and use it in GitHub Desktop.
Save saginadir/adff59de7d24fc4ac201941538df492b to your computer and use it in GitHub Desktop.
#include <iostream>
using namespace std;
int main()
{
int size, temp;
cout << "insert number" << endl;
cin >> size;
int arr[size];
for (int i=0; i < size ; i++) {
cout << "insert number " << i + 1 << " please:" << endl;
cin >> arr[i];
}
for(int i = 0; i < size ; i++)
{
for(int j = i+1; j < size ; j++)
{
if (arr[i] > arr[j]) {
temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
}
}
}
cout << endl;
for (int i=3; i>=0;i--)
{
cout<< arr[i];
if (i > 0)
cout << " , ";
}
cout << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment