Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <ctype.h>
- #include <string.h>
- int main(){
- FILE *in = fopen("input.txt", "r");
- FILE *out = fopen("output.txt", "w");
- int n;
- fscanf(in, "%d", &n);
- int mat[n][n];
- for(int i = 0; i < n; i++) {
- for(int j = 0; j < n; j++) {
- fscanf(in, "%d", &mat[i][j]);
- }
- }
- for(int i = 0; i < n / 2; i++) {
- int prv_glavna = mat[i][i];
- int prv_sporedna = mat[i][n - i - 1];
- int posleden_glavna = mat[n - i - 1][n - i - 1];
- int posleden_sporedna = mat[n - i - 1][i];
- mat[i][i] = posleden_sporedna;
- mat[i][n - i - 1] = prv_glavna;
- mat[n - i - 1][n - i - 1] = prv_sporedna;
- mat[n - i - 1][i] = posleden_glavna;
- }
- for(int i = 0; i < n; i++) {
- for(int j = 0; j < n; j++) {
- fprintf(out, "%d ", mat[i][j]);
- }
- fprintf(out, "\n");
- }
- return 0;
- }
- /*
- 4
- 88 71 24 77
- 71 32 48 32
- 50 7 39 92
- 19 64 23 1
- 5
- 1 2 3 4 5
- 6 7 8 9 10
- 11 12 13 14 15
- 16 17 18 19 20
- 21 22 23 24 25
- **/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement