Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

what i have so far: #include <iostream> #include <iomanip> #include <fstream> #i

ID: 3768900 • Letter: W

Question


what i have so far:

#include <iostream>

#include <iomanip>

#include <fstream>

#include <cstdlib> // for random functions

#include <ctime> // for argument for srand function

#include <cctype>

using namespace std;

int searchList(const int list[], int numElems, int value)

{

int index = 0; // Used as a subscript to search array

int position = -1; // To record position of search value

bool found = false; // Flag to indicate if the value was found

  

while (index < numElems && !found)

{

if (list[index] == value) // If the value is found

{

found = true; // Set the flag

position = index; // Record the value's subscript

}

index++; // Go to the next element

}

return position; // Return the position, or -1

}

//USE THIS SELECTION SORT FUNCTION (Not suppose to change)

void selectionSort(int array[], int size)

{

int startScan, minIndex, minValue;

  

for (startScan = 0; startScan < (size - 1); startScan++)

{

minIndex = startScan;

minValue = array[startScan];

for(int index = startScan + 1; index < size; index++)

{

if (array[index] < minValue)

{

minValue = array[index];

minIndex = index;

}

}

array[minIndex] = array[startScan];

array[startScan] = minValue;

}

}

//USE THE FOLLOWING for opening the input file: (Not suppose to change)

bool openInputFile( ifstream &infile )

{

string filename;

  

cout << "Enter input filename: ";

getline(cin, filename);

if( isspace(filename[filename.length()-1]) )

filename.pop_back();

infile.open(filename.c_str() );

// some compilers require .c_str()

return ! infile.fail();

} // end open;

int main(){

const int SIZE = 9;

int inputValue[SIZE]={};

int gameValue[SIZE]={};

int numElems;

int maxNum;

int matchedNum;

  

if( !readArray( inputValue, numElems, maxNum,

matchedNum, SIZE ) )

{

cout << "Unable to open the input file ";

return 1;

} //end if

//sort the values

selectionSort(values, size);

  

}

//function prototype

void selectionSort(int [], int);

bool openInputFile ( ifstream &infile);

bool readArray(int inputValue[], int numElems, int maxNum, int SIZE);

//function for reading from file

bool readArray(int inputValue [], int numElems, int maxNum, int SIZE){

ifstream infile;

int inputInt;

  

if ( !openInputFile ( infile))

return false;

infile >> maxNum;

infile >> numElems;

if ( numElems > SIZE)

numElems = SIZE;

for(int i=0; i < numElems && infile >> inputInt; ++i)

{

inputValue[i] = inputInt; // assign to array elem.

  

}

return true;

}

Explanation / Answer

#include #include using namespace std; int main() { const int size = 9; int winningDigits[size]; int player[size]; int count=0; ifstream datafile; datafile.open("player.dat"); for(int i=0; i> player[i]; if (winningDigits[i]==player[i]) count++; } /* for(int i=0; i