daily pastebin goal
20%
SHARE
TWEET

Untitled

a guest Mar 13th, 2018 52 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2.  
  3. int main() {
  4.     float mat[10][10]; #metti roba definita
  5.     int r, c;
  6.  
  7.     FILE *fpIN;
  8.  
  9.     fpIN=fopen("input.txt","r");
  10.     fscanf(fpIN, "%d %d", &r, &c);
  11.  
  12.     for (int i=0; i<r; i++)
  13.         for (int j=0; j<c; j++)
  14.             fscanf(fpIN,"%f",&mat[i][j]);
  15.  
  16.     fclose(fpIN);
  17.  
  18.     printf("\nMatrice letta da file:\n");
  19.     for (int i=0; i<r; i++){
  20.         for (int j=0; j<c; j++)
  21.             printf("%f\t",mat[i][j]);
  22.         printf("\n");
  23.     }
  24. }
  25.  
  26.  
  27. input.txt
  28. 3 3
  29. 0.33 0.456 1.23
  30. 1.33 2.456 6.23
  31. 4.33 4.456 5.23
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
 
Top