Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 0 additions & 32 deletions .gitignore

This file was deleted.

2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
all:
g++ -Wfatal-errors main.cpp
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Trio

This C++ program receives three integers and tells the user the numbers in descending (largest-to-smallest) order.

## Getting Started

To run the program do the following in your command line interface prompt ($):

```
$make
$./a.out
```
50 changes: 36 additions & 14 deletions main.cpp
Original file line number Diff line number Diff line change
@@ -1,21 +1,43 @@
#include <iostream>
using namespace std;
using std::cout;
using std::cin;
using std::endl;

void sortDescending(int,int,int);
void swap(int&,int&);

int main()
{
//DO NOT CHANGE WITHIN THIS AREA...
int red, blue, green;
cout<<"Enter Red, Green, and Blue values: ";
cin>>red>>green>>blue;
//...END OF "DO NOT CHANGE" AREA


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);
}
}

//DO NOT CHANGE WITHIN THIS AREA...
cout<<"Rearranged....\n";
cout<<"RGB: "<<red<<","<<green<<","<<blue<<endl;
return 0;
//...END OF "DO NOT CHANGE" AREA
}
void swap(int &a, int &b)
{
int temp = a;
a = b;
b = temp;
}