Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  1. void leer_matriz(int& total, int datos[10][10])
  2. {
  3.     int MaxLines;
  4.     total = 0;
  5.     ifstream Count("matriz_de_entrada.txt");
  6.     if(!Count.good()) cout<<"ERROR EN LECTURA DE MATRIZ.";
  7.     while(!Count.eof())
  8.     {
  9.         Count>>MaxLines; // ignorar, es solo para mover el cursor de lectura del archivo
  10.         total++;
  11.     }
  12.     MaxLines = int(sqrt(total));
  13.     Count.close();
  14.     ifstream File("matriz_de_entrada.txt");
  15.     if(!File.good()) cout<<"ERROR EN LECTURA DE MATRIZ.";    
  16.     for(int I = 0;I < MaxLines;I++)
  17.     {
  18.         for(int J = 0;J < MaxLines;J++)
  19.         {
  20.             File>>datos[I][J];
  21.         }
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement