-
Notifications
You must be signed in to change notification settings - Fork 0
/
moreSortFunctions.cpp
executable file
·54 lines (50 loc) · 1.65 KB
/
moreSortFunctions.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*************************************************/
//moreSortFunctions.cpp
//R. A. Hillyard
//October 15, 2001
//Implementation file gives function definitions
/*************************************************/
#include "moreSortFunctions.h"
/*****************************************************************/
//sort3 - overloaded function that sorts three integers from smallest to largest
/*****************************************************************/
void sort3(int& a, int& b, int& c)
{
if(a > b)
{ swap(a,b); }
if(a > c)
{ swap(a,c); }
if(b > c)
{ swap(b,c); }
}//end sort3
/*****************************************************************/
//swap - overloaded function that interchanges the value of two integers
/*****************************************************************/
void swap(int& a, int& b)
{
int temp = a;
a = b;
b = temp;
}//end swap
/*****************************************************************/
//sort3 - overloaded function that sorts three doubles from smallest to largest
/*****************************************************************/
void sort3(double& a, double& b, double& c)
{
if(a > b)
{ swap(a,b); }
if(a > c)
{ swap(a,c); }
if(b > c)
{ swap(b,c); }
}//end sort3
/*****************************************************************/
//swap - overloaded function that interchanges the value of two doubles
/*****************************************************************/
void swap(double& a, double& b)
{
double temp = a;
a = b;
b = temp;
}//end swap
/*****************************************************************/