Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I'm having very hard time figuring out how I would determine if an array with the same number of rows and columns has all different

I'm having very hard time figuring out how I would determine if an array with the same number of rows and columns has all different values or not (so whether if its a distinct matrix or not). I also need to be able to sort the same array using row wise approach and calculate and print its transpose. All of this should be done in C. Heres my code so far, the bolded code is me trying to determine if it has different values or not, its not working. Please help me determine if an array with the same number of rows and columns has all different values or not, sort the array using row wise approach and calculate its transpose:

#include #define MAX 100

void main() { int mat[MAX][MAX]; int i, j, m, n; int size; int rowsum, columnsum, diagonalsum; int k; int magic = 0; printf("Enter the # of rows and columns of the square matrix (must be same number): "); scanf("%d %d", &m, &n); if(m==n) { printf("Enter the elements of matrix "); for(i=0; i

printf(" Given matrix is a magic square matrix"); } else { printf(" Please enter the square matrix order(m=n) "); } int all_distinct = 1;

int count, l; for (i = 0; i < mat[i]; i++) { for(j = 0; j < mat[j]; j++) { count = 0; for(k = 0; k < mat[i]; k++) { for(l = 0; l < mat[j]; l++) { if(mat[k][l] == mat[i][j]) { count++; } } } if(count != 1) { all_distinct = 0; } } } if(all_distinct) { printf("All elements in the array are distinct "); } else { printf("All elements in the array are not distinct "); } return 0;

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Instant Reference

Authors: Gruber, Martin Gruber

2nd Edition

0782125395, 9780782125399

More Books

Students also viewed these Databases questions

Question

1. How do most insects respire ?

Answered: 1 week ago

Question

Who is known as the father of the indian constitution?

Answered: 1 week ago

Question

1.explain evaporation ?

Answered: 1 week ago

Question

Who was the first woman prime minister of india?

Answered: 1 week ago

Question

Explain the concept of going concern value in detail.

Answered: 1 week ago

Question

6. Discuss the steps involved in conducting a task analysis.

Answered: 1 week ago