我正在尝试解析数据,例如:
29 28 23 19 14 11 13 17
36 26 21 21 13 8 7 6
54 33 25 26 18 13 10 3
70 45 29 26 20 19 16 6
85 63 41 27 22 23 20 13
94 82 58 36 27 25 20 18
93 91 76 53 36 26 21 18
94 96 90 71 47 32 26 26
1.60721 -0.529301 6.88206 5.14482
27 30 32 34 37 40 39 36
6 8 10 10 12 13 14 13
2 1 2 3 4 5 7 10
3 1 2 3 5 6 7 12
5 1 1 3 4 4 7 10
11 6 3 3 5 6 8 10
12 9 4 3 5 8 11 14
16 14 11 10 13 18 24 28
0.709391 6.50125 0.745197 0.4955
39 38 37 39 40 40 40 40
20 21 21 22 23 23 24 24
14 16 17 17 16 17 18 18
12 12 13 12 12 13 13 14
12 12 12 12 12 12 11 10
13 11 11 13 14 14 13 13
17 16 17 20 22 21 21 22
34 33 34 39 40 38 40 44
6.36007 0.492539 6.03537 6.58187
使用如下算法:
restart:
Z:="C://TEMP//mydata.txt":
fclose(Z);
#M:=Array(1..100):
#V:=Array(1..100):
for i from 1 to 100 do
try
M[i]:=fscanf(Z,"%{8,8}ldm")[1];
V[i]:=fscanf(Z,"%{4}ldr")[1];
catch "end of input encountered":
break;
end try;
end do;
M[2]; # returns the 2nd entry (a 8x8 Matrix) of M
V[2]; # returns the 2nd entry (a 1x4 row Vector) of V
但它失败并出现错误,(在 fscanf 中).
读取 Vector 时遇到无效字符
我该如何解决这样的错误?