Question: 1. Write a program to fill in a two- dimensional array of boolean values by setting a[i][j] to 1 if the greatest common divisor of

 1. Write a program to fill in a two- dimensional array
of boolean values by setting a[i][j] to 1 if the greatest common

1. Write a program to fill in a two- dimensional array of boolean values by setting a[i][j] to 1 if the greatest common divisor of i and jis l. Else if the greatest common divisor is not 1, then set a[i]lj] to 0. Sample Input: ./a.out 6 Sample Output: OOOOOO 0 1 1 1 1 1 0101 01 011011 010101 0 1 1 1 1 0 Place this program in your pgm directory and call it 1.cpp. 2. Write a program to solve the Josephus problem, with the following modification: Sample Input: ./a.out nmp where n is the number of players and mis the count used for every odd turn while p is the count used for every even turn. ./a.out 5 2 3 Sample Output: Round 1: 1 -> 3 -> 4 -> 5 Round 2: 1 -> 3 -> 4 Round 3: 1 -> 4 Round 4: Winner is 1. Place this program in your pgm directory and name it 2.cpp 3. When is a graph a tree? Write a program that will read from a file specified on the command line and determine from the graph's adjacency matrix whether or not it is a tree. Example: ./a.out graph.txt Output: The graph is a tree! Contents of graph.txt will be something like this: 01000 10111 01000 01000 01000 To be graded, your program must be in your pgm and named precisely as 3.cpp

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!