Advertisement
Josif_tepe

Untitled

Aug 24th, 2023
1,109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.61 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. int main(int argc, const char * argv[]) {
  4.     FILE *in = fopen("input.txt", "r");
  5.    
  6.     int n;
  7.     fscanf(in, "%d", &n);
  8.    
  9.     int mat[n][n];
  10.     for(int i = 0; i < n; i++) {
  11.         for(int j = 0; j < n; j++) {
  12.             fscanf(in, "%d", &mat[i][j]);
  13.         }
  14.     }
  15.     for(int i = 0; i < n; i++) {
  16.         for(int j = 0; j < n; j++) {
  17.             printf("%d ", mat[i][j]);
  18.         }
  19.         printf("\n");
  20.     }
  21.    
  22.     return 0;
  23.    
  24. }
  25. /*
  26. 1 2 3 4 5 6 7 8
  27. 2 1 2 3 4 5 6 7
  28. 3 4 5 6 7 8 9 10
  29. 4 5 6 7 8 9 10 0
  30. 5 6 7 8 9 10 0 1
  31. 6 7 8 9 10 0 1 2
  32.  **/
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement