#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int ** macierz(int **, int, int);
void wypisanie(int **, int, int);
void sumowanie(int **, int, int);
int main ()
{
int N = 0;
int M = 0;
int **tab;
int i;
printf("\n Podaj liczbe kolumn oraz wierszy swojej" "macierzy KWADRATOWEJ: ");
M = N;
tab = macierz(tab, N, M);
wypisanie(tab, N, M);
sumowanie(tab, N, M);
for(i = 0; i < N; i++) {
}
return 0;
}
int ** macierz(int ** tab, int N, int M)
{
int i = 0;
int j = 0;
tab
= (int **) malloc(N
* sizeof(int*)); for(i = 0; i < M; i++)
{
tab
[i
] = (int *) malloc(M
* sizeof(int)); }
for (i = 0; i < N; i++)
for (j = 0; j < M; j++)
return tab;
}
void wypisanie(int ** tab, int N, int M)
{
int i = 0;
int j = 0;
for(i = 0; i < N; i++)
{
for(j = 0; j < M; j++)
{
}
}
}
void sumowanie(int **tab, int N, int M)
{
int skos = 0;
int nad = 0;
int pod = 0;
int i = 0;
int j = 0;
for (i = 0; i < N; i++){
for (j = 0; j < M; j++)
{
if (i < j)
{
nad += tab[i][j];
}
else if (i == j)
{
skos += tab[i][j];
}
else
{
pod += tab[i][j];
}
}
}
printf("a)\tSuma liczb macierzy nad przekatna jest rowna: %d\n", nad
); printf("b)\tSuma liczb macierzy na przekatnej jest rowna: %d\n", skos
); printf("c)\tSuma liczb macierzy pod przekatna jest rowna: %d\n", pod
); }
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KI2luY2x1ZGUgPHRpbWUuaD4KIAppbnQgKiogbWFjaWVyeihpbnQgKiosIGludCwgaW50KTsKdm9pZCB3eXBpc2FuaWUoaW50ICoqLCBpbnQsIGludCk7CnZvaWQgc3Vtb3dhbmllKGludCAqKiwgaW50LCBpbnQpOwogCmludCBtYWluICgpCnsKICAgIGludCBOID0gMDsKICAgIGludCBNID0gMDsKICAgIGludCAqKnRhYjsKICAgIGludCBpOwogCiAgICBwcmludGYoIlxuIFBvZGFqIGxpY3piZSBrb2x1bW4gb3JheiB3aWVyc3p5IHN3b2plaiIKICAgIAkibWFjaWVyenkgS1dBRFJBVE9XRUo6ICIpOwogICAgc2NhbmYoIiVkIiwgJk4pOwogICAgTSA9IE47CiAKICAgIHRhYiA9IG1hY2llcnoodGFiLCBOLCBNKTsKICAgIHd5cGlzYW5pZSh0YWIsIE4sIE0pOwogICAgc3Vtb3dhbmllKHRhYiwgTiwgTSk7CiAKICAgIGZvcihpID0gMDsgaSA8IE47IGkrKykgewogICAgCWZyZWUodGFiW2ldKTsKICAgIH0KICAgIGZyZWUodGFiKTsKICAgIAoJc3lzdGVtKCJwYXVzZSIpOwoJcmV0dXJuIDA7Cn0KIAppbnQgKiogbWFjaWVyeihpbnQgKiogdGFiLCBpbnQgTiwgaW50IE0pCnsKICAgIGludCBpID0gMDsKICAgIGludCBqID0gMDsKIAogICAgdGFiID0gKGludCAqKikgbWFsbG9jKE4gKiBzaXplb2YoaW50KikpOwogICAgZm9yKGkgPSAwOyBpIDwgTTsgaSsrKQogICAgewogICAgICAgIHRhYltpXSA9IChpbnQgKikgbWFsbG9jKE0gKiBzaXplb2YoaW50KSk7CiAgICB9CiAKICAgIHNyYW5kKCh1bnNpZ25lZCBpbnQpIHRpbWUoTlVMTCkpOwogICAgZm9yIChpID0gMDsgaSA8IE47IGkrKykKICAgICAgICBmb3IgKGogPSAwOyBqIDwgTTsgaisrKQogICAgICAgICAgICB0YWJbaV1bal0gPSByYW5kKCkgJSAxMDsKICAgICAgICAgICAgCiAgICByZXR1cm4gdGFiOwogCn0KIAp2b2lkIHd5cGlzYW5pZShpbnQgKiogdGFiLCBpbnQgTiwgaW50IE0pCnsKICAgIGludCBpID0gMDsKICAgIGludCBqID0gMDsKICAgIGZvcihpID0gMDsgaSA8IE47IGkrKykKICAgIHsKICAgICAgICBmb3IoaiA9IDA7IGogPCBNOyBqKyspCiAgICAgICAgewogICAgICAgICAgICBwcmludGYoIiVkICIsIHRhYltpXVtqXSk7CiAgICAgICAgfQogICAgICAgIHByaW50ZigiXG4iKTsKICAgIH0KfQogCnZvaWQgc3Vtb3dhbmllKGludCAqKnRhYiwgaW50IE4sIGludCBNKQp7CiAgICBpbnQgc2tvcyA9IDA7CiAgICBpbnQgbmFkID0gMDsKICAgIGludCBwb2QgPSAwOwogICAgaW50IGkgPSAwOwogICAgaW50IGogPSAwOwoKICAgIGZvciAoaSA9IDA7IGkgPCBOOyBpKyspewogICAgICAgIGZvciAoaiA9IDA7IGogPCBNOyBqKyspCiAgICAgICAgewogICAgICAgICAgICBpZiAoaSA8IGopCiAgICAgICAgICAgIHsKICAgICAgICAgICAgCW5hZCArPSB0YWJbaV1bal07CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZWxzZSBpZiAoaSA9PSBqKQogICAgICAgICAgICB7CiAgICAgICAgICAgIAlza29zICs9IHRhYltpXVtqXTsKICAgICAgICAgICAgfQogICAgICAgICAgICBlbHNlCiAgICAgICAgICAgIHsKICAgICAgICAgICAgCXBvZCArPSB0YWJbaV1bal07CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICB9CiAKICAgIHByaW50ZigiYSlcdFN1bWEgbGljemIgbWFjaWVyenkgbmFkIHByemVrYXRuYSBqZXN0IHJvd25hOiAlZFxuIiwgbmFkKTsKICAgIHByaW50ZigiYilcdFN1bWEgbGljemIgbWFjaWVyenkgbmEgcHJ6ZWthdG5laiBqZXN0IHJvd25hOiAlZFxuIiwgc2tvcyk7CiAgIAlwcmludGYoImMpXHRTdW1hIGxpY3piIG1hY2llcnp5IHBvZCBwcnpla2F0bmEgamVzdCByb3duYTogJWRcbiIsIHBvZCk7Cn0g