Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main(void) {
- int nLado, Soma = 0, sN = 0, __has = 0;
- scanf("%d", &nLado);
- int Quad[nLado][nLado], i, j;
- int Has[1024 * 1024];
- for(i = 0; i < 1024 * 1024; i++)
- Has[i] = 0;
- for(i = 0; i < nLado; i++) {
- for(j = 0; j < nLado; j++) {
- int num;
- scanf("%d", &num);
- if(Has[num - 1] == 0) {
- Quad[i][j] = num;
- Has[num - 1] = 1;
- } else {
- __has = 1;
- }
- }
- }
- for(j = 0; j < nLado; j++)
- if(!__has)
- Soma += Quad[0][j];
- for(i = 0; i < nLado && Soma != (0); i++) {
- sN = 0;
- for(j = 0; j < nLado; j++) {
- sN += Quad[i][j];
- }
- if(sN != Soma)
- Soma = 0;
- }
- for(i = 0; i < nLado && Soma != (0); i++) {
- sN = 0;
- for(j = 0; j < nLado; j++)
- sN += Quad[j][i];
- if(sN != Soma)
- Soma = 0;
- }
- sN = 0;
- for(j = 0; j < nLado && Soma != (0); j++)
- sN += Quad[j][j];
- if(sN != Soma)
- Soma = 0;
- sN = 0;
- for(j = nLado-1; j >= 0 && Soma != (0); j--)
- sN += Quad[nLado - 1 - j][j];
- if(sN != Soma)
- Soma = 0;
- printf("%d\n", Soma);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement