Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as C by matrica_okvir ( 4 years ago )
#include <stdio.h>

int main() {
    int n, matrica[100][100], jesteMeta = 1;

    do {
        printf("Unesite broj N: ");
        scanf("%d", &n);

        if (n % 2 == 0 || n < 1 || n > 100) {
            printf("Neispravna vrijednost!\n");
        }
    } while (n % 2 == 0 || n < 1 || n > 100);

    printf("Unesite matricu: ");
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            scanf("%d", &matrica[i][j]);
        }
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (matrica[i][j] != matrica[j][i]) {
                jesteMeta = 0;
                i = j = n - 1;
            }
        }
    }

    int vrijednost = matrica[0][0];

    if (jesteMeta) {
        for (int i = 1; i < n / 2 + 1; i++) {
            for (int j = 1; j < n / 2 + 1; j++) {
                if (i == j && matrica[i][j] != ++vrijednost) {
                    printf("NE");
                    return 0;
                }
            }
        }

        printf("DA");
    } else {
        printf("NE");
    }

	return 0;
}

 

Revise this Paste

Your Name: Code Language: