forked from IntroCSCI/Trio
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
45 lines (37 loc) · 686 Bytes
/
main.cpp
File metadata and controls
45 lines (37 loc) · 686 Bytes
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
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
void sortDescending(int,int,int);
void swap(int&,int&);
int main()
{
int numA, numB, numC;
cout<<"Enter any three numbers: ";
cin>>numA>>numB>>numC;
sortDescending(numA, numB, numC);
cout<<"From greatest to least, they are: ";
cout<<numA<<","<<numB<<","<<numC<<endl;
return 0;
}
void sortDescending(int first, int second, int third)
{
if( first < third )
{
swap(first,third);
}
if( first < second )
{
swap(first,second);
}
if( second < third )
{
swap(second,third);
}
}
void swap(int &first, int &second)
{
int temp = first;
first = second;
second = temp;
}