Array, using template <class>


#include <iostream>
#include <algorithm>
#include <iomanip>

using namespace std;

// Function prototypes
void DisplayA(int[], int);
void showArray(int[], int);
void DisplayB(string[], int);
void showArrayDays(string[], int);

int main()
{
int a[5] = { 10, 4, 9, 55, 11 };
string Days[7] = { "Mon", "Tue", "Wed", "Thr", "Fri", "Sat", "Sun" };
char Vowels[5] = { 'U', 'O', 'I', 'E', 'A' };

cout << "Original array\n";
cout << "a: ";
showArray(a, 5);

cout << "Days: ";
showArrayDays(Days, 7);

// Sort the array
DisplayA(a, 5);

// Display the values again
cout << "After being sorted\n";
cout << "a: ";
showArray(a, 5);


system("pause");
return 0;

}

void DisplayA(int array[], int size)
{
int i, minIndex, minValue;
for (i = 0; i < (size - 1); i++)
{
minIndex = i;
minValue = array[i];
for (int index = i + 1; index < size; index++)
{
if (array[index] < minValue)
{
minValue = array[index];
minIndex = index;
}
}
array[minIndex] = array[i];
array[i] = minValue;
}

}

void showArray(int array[], int size)
{
for (int count = 0; count < size; count++)
cout << array[count] << " ";
cout << endl;
}
hmm okay?... what do you need help with?=

Also, please use code tags http://www.cplusplus.com/articles/jEywvCM9/
Please don't post duplicate threads for the same topic.

http://www.cplusplus.com/forum/beginner/159351/

Someone with 147 posts on this forum shouldn't have to be reminded of this.
Topic archived. No new replies allowed.