Answered step by step
Verified Expert Solution
Question
1 Approved Answer
this is the first part here: ( im looking for the next parts, given in the picture. please solve the whole question, do not give
this is the first part here:im looking for the next parts, given in the picture. please solve the whole question, do not give a half reply please
#include
#include
Global enum for the type of initialization
enum initTypeList Random Checkerboard, AllWhite ;
Function to read input from the file
int readInputconst char filename int numRows int numCols int numRobots int initTypeValue unsigned int initSeed int numTurns int interval char outputFilename
FILE file fopenfilenamer;
int numScanned fscanffiled d d d u d d s numRows, numCols, numRobots, initTypeValue, initSeed, numTurns, interval, outputFilename;
fclosefile;
if numScanned
fprintfstderr "ERROR: Input file not opened correctly.
;
return ;
if numRows numRows
fprintfstderr "ERROR: The number of rows was outside the specified range to inclusive
;
return ;
if numCols numCols
fprintfstderr "ERROR: The number of columns was outside the specified range to inclusive
;
return ;
if numRobots numRobots
fprintfstderr "ERROR: The number of robots was outside the specified range to inclusive
;
return ;
if initTypeValue initTypeValue
fprintfstderr "ERROR: The initTypeValue was outside the specified range to inclusive
;
return ;
if initSeed initSeed
fprintfstderr "ERROR: The initSeed was outside the specified range to inclusive
;
return ;
if numTurns numTurns
fprintfstderr "ERROR: The number of turns was outside the specified range to inclusive
;
return ;
if interval interval numTurns
fprintfstderr "ERROR: The printing interval was outside the specified range to number of turns inclusive
;
return ;
return ;
int main
char filename;
printfEnter the name of the input file: ;
scanfs filename;
int numRows, numCols, numRobots, initTypeValue, numTurns, interval;
unsigned int initSeed;
char outputFilename;
int attempts ;
while readInputfilename &numRows, &numCols, &numRobots, &initTypeValue, &initSeed, &numTurns, &interval, outputFilename
attempts;
if attempts
fprintfstderr "ERROR: Failed to open the input file times. Terminating the program.
;
return ;
printfEnter the name of the input file: ;
scanfs filename;
printfInput read successfully!
;
printfNumber of Rows: d
Number of Columns: d
Number of Robots: d
Initialization Type: d
Seed: u
Number of Turns: d
Printing Interval: d
Output Filename: s
numRows, numCols, numRobots, initTypeValue, initSeed, numTurns, interval, outputFilename;
return ;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started