Question: Use of advanced C + + code techniques, in this assignment, is prohibited. Limit commands to those discussed in the current and previous chapters, labs,

Use of advanced C++ code techniques, in this assignment, is prohibited. Limit commands to those
discussed in the current and previous chapters, labs, and lectures.
Do not share your code. If you get help or discuss this assignment with another individual, include
their name(s) in the header comments.
Each time you indent code, use four spaces. Never use TAB characters in source code or program
output.
Do not use the break or continue statements within selection or repetition structures (other
than switch structures.
Submit questions regarding this assignment at least 24 to 48 hours before it is due to allow time for
a response that you can implement.
Problem description
In the context of binary matrices, the evenness or oddness of the number of ones in each row and column of a
matrix determines whether it is balanced or corrupt.
More specifically, if a binary matrix is balanced, then each row and each column has an even number of ones, or
equivalently, the sum of each row and column is an even number. If a binary matrix is not balanced, then there
is at least one row or column with an odd number of ones, and the matrix is considered corrupt.
This is useful in certain applications, such as error-correcting codes, because it can be used to detect errors in
data transmission. For example, if a transmitted message is represented as a balanced binary matrix, then any
errors in the transmission will result in a matrix that is not balanced, indicating that an error has occurred, i.e.,
it's corrupt.
For example, the 44 matrix shown below is balanced:
In this matrix, each row and column has an even sum. Specifically, the rows have sums of 4,2,2, and 0, and the
columns have sums of 2,2,2, and 2.
Your task is to create a program that reads in a matrix and checks whether it is balanced. If the matrix is not
balanced, your program should determine whether it can become balanced by changing only one bit. If it is
impossible to balance the matrix by changing one bit, the matrix should be classified as "corrupt."
Input
The input stream will consist of one or more test cases. For each test case, the first line will contain a single
integer N(1N128) indicating the size of the matrix. The matrix will be provided in the
subsequent N lines, with N integers per line. The matrix will only consist of and 1, and no other integers will
be present. The end of the input will be indicated by a value of 0 for N.
Output
For every matrix in the input stream, output one line. If the matrix is already balanced, then print "Balanced". If
balance can be achieved by changing a single bit, then output "Toggle bit [ij]", where is the row number and j is
the column number of the bit to be modified. Otherwise, output "Corrupt".
Sample input (file pa08b-input0.txt)
Sample output
$? paesb paesb-inpute.txt
Balanced
Toggle bit 2,3
corrupt
Steps
Read the input, including the matrix size N and the NN binary matrix.
Check if the matrix is balanced by calculating the sum of ones in each row and column.
If the matrix is balanced, print "Balanced" and proceed to the next test case.
If the matrix is not balanced, determine if changing a single bit can achieve balance.
If a single bit change achieves balance, print "Toggle bit [ij]" with the row and column indices of the
modified element.
If balance cannot be achieved by changing a single bit, print "Corrupt".
Repeat steps 1-6 for each test case in the input stream.
Specific program requirements
DO use only language features introduced in chapters 1-8, lecture, or sample solutions.
Use of advanced C + + code techniques, in this

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 Programming Questions!