Created
May 29, 2012 17:34
-
-
Save brand-it/2829654 to your computer and use it in GitHub Desktop.
Sort array calculation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
#include <iomanip> | |
using namespace std; | |
const int array_size = 9; | |
int array_of_numbers[array_size]; | |
void exchangeSort(){ | |
int i, j; | |
int temp; | |
for (i=0; i <= array_size; i++) { | |
for(j = i; j <= array_size; j++){ | |
if (array_of_numbers[i] > array_of_numbers[j]){ | |
temp= array_of_numbers[i]; | |
array_of_numbers[i] = array_of_numbers[j]; | |
array_of_numbers[j] = temp; | |
} | |
} | |
} | |
} | |
void main() { | |
cout << "Please enter the numbers you would like to order" << endl; | |
for(int count = 0; count <= array_size; count++){ | |
cout << "Please enter a number for number " << count + 1 << ":"; | |
cin >> array_of_numbers[count]; | |
} | |
exchangeSort(); | |
cout << "The array has been ordered and printed below" << endl; | |
for(int count = 0; count <= array_size; count++){ | |
cout << array_of_numbers[count] << " "; | |
} | |
cout << endl; | |
system("pause"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment