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

Problem: Write an OpenMP program to transpose a given matrix. The input for this

ID: 3651661 • Letter: P

Question

Problem: Write an OpenMP program to transpose a given matrix. The
input for this program will be from a text file. The name of the file
will be matrix.txt and will be in your pgm directory. In the above
example the matrix.txt file would be:
3 3
1 2 8
3 4 3
5 6 1
Example Output:
1 3 5
2 4 6

What I have below is in pseudocode but I do not know how to convert it to C++ and I am not sure if this is correct for this problem.



procedure transpose_matrix (matrix)
result := []
# for each column
every (i := 1 to *matrix[1]) do {
col := []
# extract the number in each row for that column
every (row := !matrix) do put (col, row[i])
# and push that column as a row in the result matrix
put (result, col)
}
return result
end

procedure print_matrix (matrix)
every (row := !matrix) do {
every writes (!row || " ")
write ()
}
end

procedure main ()
matrix := [[1,2,3],[4,5,6]]
write ("Start:")
print_matrix (matrix)
transposed := transpose_matrix (matrix)
write ("Transposed:")
print_matrix (transposed)
end

Explanation / Answer

///////This code is for 3x3 matrix,u can modify in the way you like :P #include #include void swap(int *x,int *y); main() { int i,j,k,m,n; int matrix[3][3]; printf("Enter the matrix: "); for (i=0;i
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote