Joined: Sun May 25, 2008 5:34 pm Posts: 95 Has thanked: 2 time Have thanks: 1 time
Code:
#include <iostream> #include <algorithm>
using namespace std;
/* * This program reads in integers and sorts them using the library sort * function. The algorithm header provides the sorting function. * * Author: Tom Bennet */
const int MAX_NUM_INTS = 100; int main() { int ints[MAX_NUM_INTS]; // Where the numbers go.
// Read them in. int i; for(i = 0; i < MAX_NUM_INTS && cin >> ints[i]; ++i); int numints = i;
// Sort them. The library sort algorithm wants a pointer to the // the start of the data, and a pointer one past the end. sort(ints, ints + numints);