Functions Poiters to Arrays, simple sorting

for this assignment you will complete and test 7 functions

as always start by copying over all the files provided for you



Since these are template functions you will put the functions bodies in "functions.h"

there are functons 
bool IsSortedAccending(T * array, int size)
bool IsSortedDecending(T * array, int size 
in cmpslib19.h you should use to test to see if it is sorted..



run the example and mimic what it does in your main

MAKE SURE your logging is done like the example.log


File: functions.h 



#pragma once
#include "cmpslib19.h"
#include "fraction.h"
#include "easylogging++.h"


// NOTE THAT YOU CANNOT USE THE INDEX OPERATOR IN  BOTH SORTS
// AS DESCRIBED BELOW , READ IT

// SortAscending
// template function
//   use the index operator [] to access and modify the elements DO NOT use the Indirection  (*) operator
//   use the BUBBLE sort logic below and the logging suggested there as well

// SortDescending
// template function
//   use pointer arithmetic and the Indirection operator (*)   DO NOT use the  index operator ([])
//   use the BUBBLE sort logic below and the logging suggested there as well

// PrintArray
// template function
//   the format should be like:
//   Position:1 value:29
//   look at the output of the runnable example if you are unsure

// FillArrayWithRandom (pointer to the array of type Cfraction, size of the array)
// NOT A TEMPLATE function this one is specific for an array of Cfraction
//   fill the array pointed to by (target) with (count) elements
//   you MUST use the CreateRandomNumber function in cmpslib19.h
//   to change the value of a fraction you will need to call
//   SetNumerator and SetDenominator functions
//   make the numerator a random value from 0-100
//   make the denominatory random value from 1-100


// FillArrayWithRandom (pointer to the array, size of the array, min val, max val
// template function
//   fill the array pointed to by (target) with (count) elements
//   you MUST use the CreateRandomNumber function in cmpslib19.h



// LargestInArray
// template function
// array parameter is "const T *"
//   return a copy of the largest value found
//   do not modify the values in the array

// SmallestInArray
// template function
// array parameter is "const T *"
//   return a copy of the smallest value found
//   do not modify the values in the array





for full credit: 1 do all the test for both integer and fraction types 2 make sure you log your functions like the example does..LOOK at the example log file 3 be sure not to use the [] index operator in both sorts.. one use * the other [] 4 use the IsSortedAccending and IsSortedDecending functions from cmpslib.h functions.h -- put your function bodies here ( they are template functions ) main1.cpp -- create a main to test that your functions do what they are supposed to do
use a BUBBLE SORT with two nested for loops, do NOT use a do-while or while loop for each iteration of the inner loop compare an element in the array with the element IMMEDIATELY following it for example compare position 0 with 1, 1 with 2, 2 with 3, 3 with 4, 4 with 5 and so on DO NOT VARY FROM THE BELOW LOGIC pseudo code: count is the number of elements in the array myarray is the name of the array for (outerloop 0 to less than count) { for (innerloop 0 to less than count -1) { LOG that you are comparing position ( innerloop ) with (innerloop+1) ..ie "comparing postition 5 with 6, the values are 57 and 22" compare array position innerloop with innerloop+1 swap the values if necessary LOG that you are swapping position (innerloop) with (innerloop+1) ..ie "swapping postition 5 with 6, the values are 57 and 22" } }
determining the largest value in an array