lab19 - Lab 19 Source File: Input: Output: Value:...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Lab 19 Due Date: Wednesday, October 5, 2011 Source File: ~/2305/lab19.C Input: under control of main function Output: under control of main function Value: 2 Write a template function whose prototype is given by 1 template<typename T> 2 void Swap(T& first, T& second); The function swaps the contents of first and second . Write a second template function whose prototype is given by 1 template<typename T> 2 void BubbleSort(T *array, int n); The function sorts the n -element array array in ascending order using a bubble sort. The sort algorithm should incorporate two enhancements: the length of the list should be diminished by one on each pass of the inner loop and the algorithm should terminate early if no swaps are made on a pass. A main function for testing your functions is shown in Figure 1. The expected output from executing this code is shown in Figure 2. To use the Makefile as distributed in class, add a target of lab19main to targets1srcfile . 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 10/13/2011 for the course CS 2305 taught by Professor Motl,m during the Fall '08 term at Angelo State.

Page1 / 2

lab19 - Lab 19 Source File: Input: Output: Value:...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online