Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Java (http://www.go4expert.com/forums/java/)
-   -   read matrix input file and store it in matrix (http://www.go4expert.com/forums/read-matrix-input-file-store-matrix-t16938/)

shima 16Apr2009 16:44

read matrix input file and store it in matrix
 
hi,

i having problem in reading input value in matrix form and store it in matrix.

below is a sample of my input file (ref.txt)

A1 A2 A3 A4 A5 A6 A7 A8
q1 1 0 0 1 0 1 1 0
q2 0 1 1 0 1 0 0 0
q3 0 0 0 1 0 0 1 1
q4 0 1 0 0 0 1 0 1
q5 1 0 0 0 0 0 1 0
q6 0 0 1 0 1 0 0 1

how should i read this kind of input???

asadullah.ansari 17Apr2009 09:46

Re: read matrix input file and store it in matrix
 
take two loop one is for row means end of file and other is for column means end of line...
and skip white space(according to your text file)...
Example:
Code:

for i=0 to EOF
  for j=0 to EOL
        Skip according to your file which character  you have to skip menas like white space
        Mat[i][j]= read contents by file Pointer



All times are GMT +5.5. The time now is 09:31.