SHARE
TWEET

Untitled

a guest Oct 20th, 2019 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. void swap(int** mass,int size){
  5.     int temp;
  6.     int center;
  7.     center = size / 2;
  8.  
  9.     for (int i = 0; i < (size - center); i++) {
  10.         for (int j = 0; j < (size - center); j++) {
  11.             temp = mass[j][i];
  12.             mass[j][i] = mass[j + center][i + center];
  13.             mass[j + center][i + center] = temp;
  14.         }
  15.     }
  16.  
  17.     for (int i = size; i <= (center + 1) ; --i) {
  18.         for (int j = 0; j >= (center - 1); j++) {
  19.             temp = mass[j][i];
  20.             mass[j][i] = mass[j + center][i - center];
  21.             mass[j + center][i - center] = temp;
  22.         }
  23.     }
  24.  
  25.  
  26.     printf("Полученная матрица: \n");
  27.     for (int i = 0; i < size; ++i) {
  28.         for (int j = 0; j < size; ++j) {
  29.             printf("%d \t",mass[i][j]);
  30.         }
  31.         printf("\n");
  32.     }
  33. }
  34.  
  35. int main() {
  36.     int size;
  37.     FILE* in = fopen("111.txt", "r+");
  38.     fscanf(in,"%d", &size);
  39.     int** mass = (int**)malloc(size*sizeof(int*));
  40.     for (int i = 0; i < size; i++){
  41.         mass[i] = (int*)malloc(size* sizeof(int));
  42.         for (int j = 0; j < size; j++) {
  43.             fscanf(in, "%d", &mass[i][j]);
  44.         }
  45.     }
  46.     fclose(in);
  47.     for (int i = 0; i < size; i++){
  48.         for (int j = 0; j < size; j++) {
  49.             printf( "%d \t", mass[i][j]);
  50.         }
  51.         printf("\n");
  52.     }
  53.     swap(mass,size);
  54. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top