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.

4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
language: cpp
os: linux
script:
- make
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
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[![Build Status](https://travis-ci.com/krasmussen3/Trio.svg?branch=master)](https://travis-ci.com/krasmussen3/Trio)
# 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
```
55 changes: 43 additions & 12 deletions main.cpp
Original file line number Diff line number Diff line change
@@ -1,25 +1,56 @@
#include <iostream>
using namespace std;
using std::cout;
using std::cin;
using std::endl;

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

// <-- ADD YOUR FUNCTION PROTOTYPE HERE

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
//Takes user input and stores in int variables
int numA, numB, numC;
cout<<"Enter any three numbers: ";
cin>>numA>>numB>>numC;


//Number sorting Function
sortDescending(numA, numB, numC);
//Outputs sorted numbers to the user
cout<<"From greatest to least, they are: ";
cout<<numA<<","<<numB<<","<<numC<<endl;

// <-- ADD YOUR FUNCTION CALL HERE


//DO NOT CHANGE WITHIN THIS AREA...
cout<<"Rearranged....\n";
cout<<"RGB: "<<red<<","<<green<<","<<blue<<endl;
return 0;
//...END OF "DO NOT CHANGE" AREA

}
//Compares numbers in the list and swaps them if they pervious number is
//greater than the following
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);
}
}


// <-- ADD YOUR FUNCTION DEFINITON HERE
//Helper Function to sortDescending that swaps numbers
void swap(int &first, int &second)
{
int temp = first;
first = second;
second = temp;
}
//...END OF "DO NOT CHANGE" AREA