Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- void mirror(int **t, int n)
- {
- int i, j;
- for(i = 0; i < n; ++i)
- {
- for(j = 0; j < n - i ;++j)
- {
- if(j+1+i != n)
- {
- int swap = t[i][j];
- t[i][j] = t[n-j-1][n-i-1];
- t[n-j-1][n-i-1] = swap;
- }
- }
- }
- }
- 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");
- }
- printf("\n");
- mirror(t, 5);
- for(i = 0; i < 5; ++i)
- {
- for(j = 0; j < 5; ++j)
- printf("%d ", t[i][j]);
- printf("\n");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement