Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- typedef struct matrixTipus{
- int **matrix;
- int sorok;
- int oszlop;
- } matrixTipus;
- void lefoglalMatrix(matrixTipus * m)
- {
- m->matrix = (int**)malloc(m->sorok*sizeof(int*));
- int i,j;
- for(i = 0; i<m->sorok; i++)
- {
- m->matrix[i]=(int*)malloc(m->oszlop*sizeof(int));
- for(j=0; j<m->oszlop; j++)
- {
- m->matrix[i][j]=i+j;
- }
- }
- }
- void lefoglal(int *** m, int sor, int oszlop)
- {
- (*m) = (int**)malloc(sor*sizeof(int*));
- int i,j;
- for(i = 0; i<sor; i++)
- {
- (*m)[i]=(int*)malloc(oszlop*sizeof(int));
- for(j=0; j<oszlop; j++)
- {
- (*m)[i][j]=i+j;
- }
- }
- }
- void kiir(int ** m, int sorok, int oszlopok)
- {
- int i ,j;
- for(i=0; i<sorok; i++)
- {
- for(j=0; j<oszlopok; j++)
- {
- printf("%3d ",m[i][j]);
- }
- printf("\n");
- }
- }
- void felszabadit(int *** m, int sorok)
- {
- int i;
- for(i=0; i<sorok; i++)
- {
- free( (*m)[i] );
- }
- free(*m);
- *m = 0;
- }
- int main(void) {
- /*int sorok = 5;
- int oszlopok = 7;*/
- matrixTipus matrix;
- matrix.sorok = 5;
- matrix.oszlop = 7;
- /*int ** matrix = 0;
- lefoglal(&matrix, sorok, oszlopok);
- kiir(matrix,sorok,oszlopok);
- felszabadit(&matrix, sorok);*/
- return 0;
- }
Add Comment
Please, Sign In to add comment