這應該讓你開始 - 我得到儘可能讀取文件,分割線,並轉換字符串實數:
Program Test;
var
fileVar: Text;
l: string[81];
inputFilename: string[14];
lCount: Integer;
i: Integer;
code: Integer;
spacePos: Integer;
firstName: string[100];
secondName: string[100];
num1: real;
num2: real;
product: real;
s: string[100];
begin
inputFilename := 'input.txt';
Assign(fileVar, inputFilename);
Reset(fileVar);
Readln(fileVar, l);
Val(l, lCount);
Writeln('l count=', lCount);
for i := 1 to lCount do
begin
Readln(fileVar, l);
spacePos := Pos(' ', l);
firstName := Copy(l, 0, spacePos);
Delete(l, 1, spacePos);
spacePos := Pos(' ', l);
secondName := Copy(l, 0, spacePos);
Delete(l, 1, spacePos);
spacePos := Pos(' ', l);
s := Copy(l, 0, spacePos - 1);
Val(s, num1, code);
Delete(l, 1, spacePos);
Val(l, num2, code);
WriteLn(firstName);
Writeln(secondName);
Writeln(num1);
Writeln(num2);
end;
Close(fileVar);
end.
帕斯卡的現代化身是德爾福(在Windows和OS-X )和所有其他平臺上的Lazarus。 – Johan