Uploading last bits
+- StateUtilities.c +- PA02_Main.c +- PA02_Main +- outDebug
This commit is contained in:
parent
9eed1d98d3
commit
ae256e5ac2
4 changed files with 30 additions and 17 deletions
Binary file not shown.
|
|
@ -51,7 +51,7 @@ int main()
|
||||||
|
|
||||||
// display original list
|
// display original list
|
||||||
displayData( wkgArray, wkgNumStates, "Original data after upload" );
|
displayData( wkgArray, wkgNumStates, "Original data after upload" );
|
||||||
/*
|
|
||||||
// find state
|
// find state
|
||||||
printf( "\nFinding state: %s\n", searchData.name );
|
printf( "\nFinding state: %s\n", searchData.name );
|
||||||
findStateByName( &resultData, wkgArray, wkgNumStates, searchData );
|
findStateByName( &resultData, wkgArray, wkgNumStates, searchData );
|
||||||
|
|
@ -72,7 +72,7 @@ int main()
|
||||||
// display original list
|
// display original list
|
||||||
displayData( wkgArray, wkgNumStates,
|
displayData( wkgArray, wkgNumStates,
|
||||||
"Original data after state removal" );
|
"Original data after state removal" );
|
||||||
|
/*
|
||||||
// bubble sort
|
// bubble sort
|
||||||
// function: runBubbleSort
|
// function: runBubbleSort
|
||||||
runBubbleSortByName( sortingArray, sortingNumStates );
|
runBubbleSortByName( sortingArray, sortingNumStates );
|
||||||
|
|
|
||||||
|
|
@ -104,9 +104,14 @@ Dependencies: as needed
|
||||||
*/
|
*/
|
||||||
void copyArray( StateDataType *dest, const StateDataType *src, int srcSize )
|
void copyArray( StateDataType *dest, const StateDataType *src, int srcSize )
|
||||||
{
|
{
|
||||||
|
int currentSize;
|
||||||
// use a for loop to iterate through source array (start at zero, go to srcSize)
|
// use a for loop to iterate through source array (start at zero, go to srcSize)
|
||||||
// copy each element from the array to the new array.
|
for(currentSize = 0; currentSize < srcSize; currentSize++)
|
||||||
// uses deepCopy to do this.
|
{
|
||||||
|
// copy each element from the array to the new array.
|
||||||
|
// uses deepCopy to do this.
|
||||||
|
deepCopy(dest, *src);
|
||||||
|
}
|
||||||
// no return, void
|
// no return, void
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -226,7 +231,7 @@ void displayData( const StateDataType *array, int size, const char *subTitle )
|
||||||
printCharacter(PIPE);
|
printCharacter(PIPE);
|
||||||
// print new line
|
// print new line
|
||||||
printEndline();
|
printEndline();
|
||||||
for(countStates = 0; countStates <= size; countStates++)
|
for(countStates = 0; countStates < size - 1; countStates++)
|
||||||
{
|
{
|
||||||
// use the constants to format the table
|
// use the constants to format the table
|
||||||
// print PIPE character
|
// print PIPE character
|
||||||
|
|
@ -244,7 +249,7 @@ void displayData( const StateDataType *array, int size, const char *subTitle )
|
||||||
// print PIPE character
|
// print PIPE character
|
||||||
printCharacter(PIPE);
|
printCharacter(PIPE);
|
||||||
// print growth justified right, need a % sign too. (requires some math trickery to make work)
|
// print growth justified right, need a % sign too. (requires some math trickery to make work)
|
||||||
printDoubleJustified(array[countStates].growth, PRECISION_2, GROWTH_BLOCK_SIZE - 2, "RIGHT");
|
printDoubleJustified(array[countStates].growth * 100.00, PRECISION_2, GROWTH_BLOCK_SIZE - 2, "RIGHT");
|
||||||
printCharacter('%');
|
printCharacter('%');
|
||||||
printCharacter(SPACE);
|
printCharacter(SPACE);
|
||||||
// print PIPE character
|
// print PIPE character
|
||||||
|
|
@ -281,9 +286,6 @@ void displayData( const StateDataType *array, int size, const char *subTitle )
|
||||||
printCharacters(MAJORITY_BLOCK_SIZE, DASH);
|
printCharacters(MAJORITY_BLOCK_SIZE, DASH);
|
||||||
// print PIPE character
|
// print PIPE character
|
||||||
printCharacter(PIPE);
|
printCharacter(PIPE);
|
||||||
/* testing
|
|
||||||
*/
|
|
||||||
printf("Iteration: %d", countStates);
|
|
||||||
// print endline
|
// print endline
|
||||||
printEndline();
|
printEndline();
|
||||||
}
|
}
|
||||||
|
|
@ -315,10 +317,19 @@ Dependencies: as needed
|
||||||
bool findStateByName( StateDataType *foundElement,
|
bool findStateByName( StateDataType *foundElement,
|
||||||
const StateDataType *array, int size, const StateDataType searchValue )
|
const StateDataType *array, int size, const StateDataType searchValue )
|
||||||
{
|
{
|
||||||
|
int nameCount;
|
||||||
// iterate through array
|
// iterate through array
|
||||||
// check to see if the state name is found (use searchValue)
|
for(nameCount = 0; nameCount < size; nameCount++)
|
||||||
// copy the element out of the array, put in foundElement
|
{
|
||||||
// return true
|
// check to see if the state name is found (use searchValue)
|
||||||
|
if(strcmp(array[nameCount].name, searchValue.name) == 0)
|
||||||
|
{
|
||||||
|
// copy the element out of the array, put in foundElement
|
||||||
|
deepCopy(foundElement, array[nameCount]);
|
||||||
|
// return true
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
// otherwise, return false
|
// otherwise, return false
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -342,13 +353,15 @@ Dependencies: as needed
|
||||||
bool removeStateByName( StateDataType *removedElement,
|
bool removeStateByName( StateDataType *removedElement,
|
||||||
StateDataType *array, int *size, const StateDataType searchVal )
|
StateDataType *array, int *size, const StateDataType searchVal )
|
||||||
{
|
{
|
||||||
|
bool stateNameFound;
|
||||||
|
stateNameFound = findStateByName();
|
||||||
// iterate through array
|
// iterate through array
|
||||||
// use the findStateByName to search
|
// use the findStateByName to search
|
||||||
// remove the element by copying the next element into last slot until end
|
// remove the element by copying the next element into last slot until end
|
||||||
// reduce the size by one
|
// reduce the size by one
|
||||||
// return true
|
// return true
|
||||||
// otherwise, return false
|
// otherwise, return false
|
||||||
return NULL;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -529,7 +542,7 @@ int uploadStateData( StateDataType *StateDataArray,
|
||||||
readStringToDelimiterFromFile(COMMA, currentString);
|
readStringToDelimiterFromFile(COMMA, currentString);
|
||||||
// find a way to cast string to double, using sscanf.
|
// find a way to cast string to double, using sscanf.
|
||||||
sscanf(currentString, "%lf", &growthUpload);
|
sscanf(currentString, "%lf", &growthUpload);
|
||||||
stateUpload->growth = growthUpload * 100;
|
stateUpload->growth = growthUpload;
|
||||||
// read in the majority, store
|
// read in the majority, store
|
||||||
readStringToDelimiterFromFile(COMMA, currentString);
|
readStringToDelimiterFromFile(COMMA, currentString);
|
||||||
// get the first character of currentString
|
// get the first character of currentString
|
||||||
|
|
|
||||||
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue