Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int is_mirror(int **t, int n)
- {
- int i, j;
- for(i = 0; i < n; ++i)
- {
- for(j = 0; j < n ;++j)
- {
- if(t[i][j]!=t[j][i]) return 0;
- }
- }
- return 1;
- }
- int main(void) {
- int i, j, **t;
- t =(int**) malloc(5*sizeof(int*));
- for(i = 0; i < 5; ++i)
- {
- t[i] = (int*) malloc(5*sizeof(int));
- }
- for(i = 0; i < 5; ++i)
- {
- for(j = 0; j < 5; ++j)
- t[i][j] = (i+1)*(j+1);
- }
- for(i = 0; i < 5; ++i)
- {
- for(j = 0; j < 5; ++j)
- printf("%d ", t[i][j]);
- printf("\n");
- }
- if(is_mirror(t, 5)) printf("Szimmetrikus!\n");
- else printf("Nem szimmetrikus!\n");
- t[0][1] = 1;// rontás
- for(i = 0; i < 5; ++i)
- {
- for(j = 0; j < 5; ++j)
- printf("%d ", t[i][j]);
- printf("\n");
- }
- if(is_mirror(t, 5)) printf("Szimmetrikus!\n");
- else printf("Nem szimmetrikus!\n");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement