Full Code: #include #include #include #define seed 5457 #define max(a,b) \ ({ __typeof__ (a) _a = (a); \ __typeof__ (b) _b = (b); \ _a > _b ? _a : _b; }) #define min(a,b) \ ({ __typeof__ (a) _a = (a); \ __typeof__ (b) _b = (b); \ _a < _b ? _a : _b; }) int initializeArray(int [], const int); void randperm(int b[], int n); int checkboard(int b[], int n); void displayboard(int b[], int n); double factorial(double n); int main() { srandom(seed); int mini[21], maxi[21]; double meani[21], sizei[21], sizei_f[21]; int n; for (n=4; n<=20; n++) { int b[n]; initializeArray(b,n); printf("~~~~~~~~~PRINTING FOR %d~~~~~~~~~~~~~\n",n);    int total = 0; int x; for (x = 0; x<10; x++) { int count = 1; randperm(b,n); while(!checkboard(b,n)) { randperm(b,n);    count++; } if (x==0) { mini[n] = count; maxi[n] = count; displayboard(b,n); } mini[n] = min(mini[n],count); maxi[n] = max(maxi[n], count); total += count; } meani[n] = total/10.0f; double size = pow(n,n); sizei[n] = size; double size_f = factorial(n); sizei_f[n] = size_f;    } printf("\n%13s%13s%13s%13s%13s%13s\n", "size", "min", "max", "mean", "size**size", "size!"); int x; for (x=4; x<=20; x++) { printf("%13d%13d%13d%13.1e%13.1e%13.1e\n", x, mini[x], maxi[x], meani[x], sizei[x], sizei_f[x]); } } int initializeArray(int *a, const int arraySize) { int i; for (i=0; i { a[i] = i; } } void randperm(int b[], int n) { int i; for (i=n-1; i>0; i--) { int j; int temp; j = random() % (i+1); temp = b[j]; b[j] = b[i]; b[i] = temp; } } int checkboard(int b[], int n) { int x; for (x = 0; x { int z; for (z=x+1; z { if (abs(x-z) == abs(b[x]-b[z])) { return 0; } } } return 1; } void displayboard(int b[], int n) { int x; for (x=0; x { int i; for (i = 0; i < n; i++) { if (i == b[x]) { printf("*"); } else printf("-");    } printf("\n"); } } double factorial(double n) { if (n==1) { return 1; } else { return n*factorial(n-1); } } Can you replace the part below with something else for the same outcome? Replace this part in the Full Code: #define max(a,b) \ ({ __typeof__ (a) _a = (a); \ __typeof__ (b) _b = (b); \ _a > _b ? _a : _b; }) #define min(a,b) \ ({ __typeof__ (a) _a = (a); \ __typeof__ (b) _b = (b); \ _a < _b ? _a : _b; })

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Full Code:

#include
#include
#include

#define seed 5457

#define max(a,b) \
({ __typeof__ (a) _a = (a); \
__typeof__ (b) _b = (b); \
_a > _b ? _a : _b; })

#define min(a,b) \
({ __typeof__ (a) _a = (a); \
__typeof__ (b) _b = (b); \
_a < _b ? _a : _b; })

int initializeArray(int [], const int);
void randperm(int b[], int n);
int checkboard(int b[], int n);
void displayboard(int b[], int n);
double factorial(double n);

int main()
{
srandom(seed);
int mini[21], maxi[21];
double meani[21], sizei[21], sizei_f[21];
int n;
for (n=4; n<=20; n++)
{
int b[n];
initializeArray(b,n);
printf("~~~~~~~~~PRINTING FOR %d~~~~~~~~~~~~~\n",n);
  
int total = 0;
int x;
for (x = 0; x<10; x++)
{
int count = 1;
randperm(b,n);
while(!checkboard(b,n))
{
randperm(b,n);
  
count++;
}
if (x==0)
{
mini[n] = count;
maxi[n] = count;
displayboard(b,n);
}
mini[n] = min(mini[n],count);
maxi[n] = max(maxi[n], count);
total += count;

}
meani[n] = total/10.0f;
double size = pow(n,n);
sizei[n] = size;
double size_f = factorial(n);
sizei_f[n] = size_f;
  
}
printf("\n%13s%13s%13s%13s%13s%13s\n", "size", "min", "max", "mean", "size**size", "size!");

int x;
for (x=4; x<=20; x++)
{
printf("%13d%13d%13d%13.1e%13.1e%13.1e\n", x, mini[x], maxi[x], meani[x], sizei[x], sizei_f[x]);
}

}

int initializeArray(int *a, const int arraySize)
{
int i;
for (i=0; i {
a[i] = i;
}
}

void randperm(int b[], int n)
{
int i;
for (i=n-1; i>0; i--)
{
int j;
int temp;
j = random() % (i+1);
temp = b[j];
b[j] = b[i];
b[i] = temp;
}
}

int checkboard(int b[], int n)
{
int x;
for (x = 0; x {
int z;
for (z=x+1; z {
if (abs(x-z) == abs(b[x]-b[z]))
{
return 0;
}
}
}
return 1;
}

void displayboard(int b[], int n)
{
int x;
for (x=0; x {
int i;
for (i = 0; i < n; i++)
{
if (i == b[x])
{
printf("*");
}
else
printf("-");
  
}
printf("\n");
}
}

double factorial(double n)
{
if (n==1)
{
return 1;
}
else
{
return n*factorial(n-1);
}
}

Can you replace the part below with something else for the same outcome?

Replace this part in the Full Code:

#define max(a,b) \
({ __typeof__ (a) _a = (a); \
__typeof__ (b) _b = (b); \
_a > _b ? _a : _b; })

#define min(a,b) \
({ __typeof__ (a) _a = (a); \
__typeof__ (b) _b = (b); \
_a < _b ? _a : _b; })

Expert Solution
steps

Step by step

Solved in 6 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY