Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int main(){
- int a = 4;
- int c[16]= {1, 2, 3, 4, 7, 1, 2, 3, 8, 7, 1 , 2, 9, 8, 7, 1};
- is_same_diagonals (a, c[16]);
- }
- int is_same_diagonals (int n, int a[]){
- int condition = 0;
- int j = 0;
- for (int firsthalf = 0; firsthalf < n-1; firsthalf++)
- {
- for ()
- while (j < n*n )
- {
- if (a[firsthalf] == a[j])
- {
- condition == 1;
- j = j + (n+1);
- }
- else
- {
- condition == 0;
- }
- j++;
- }
- }
- if (condition == 1)
- {
- int sechalf;
- for (int sechalf = n; sechalf < n*n; sechalf += n);
- {
- for (int x = n; x < n*n; x += (n+1))
- {
- if ( a[sechalf] == a[x])
- {
- condition == 1;
- }
- else
- {
- condition == 0;
- }
- }
- }
- }
- if (condition == 1)
- {
- printf("The matrix qualifies as having diagonals with the same values.");
- }
- else
- {
- printf("The matrix doesn't qualify as having diagonals with the same value.");
- }
- return (condition);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement