English 中文(简体)
板块分割成实际和扼杀线
原标题:Pascal splitting line into real and strings

I know that this language have died a couple of years ago, but still required in most of schools in our country -.- I got file with data, which looks like:

  • Number of lines
  • Name Surname (real type digit) (another real type digit)

例如:

  • 2
  • Brat Sunbather 5.66 55.4
  • Bart Simpson 55.7 45.4

并且,我需要创建结果文件,这样看:

  • Name Surname (Previously given real type digits multiplied)
  • Total

例如:

  • Brat Sunbather 313.56
  • Bart Simpson 2528.78
  • Total: 2842.34

我不敢试图将这条线分割成形状和真实的线,即便在例子中提供的书一中,所有数据都是单独线的:

  • String
  • Digit
  • String
  • Digit

我可以找到任何东西,希望你们能够帮助我。 事先感谢你。

最佳回答

这应当让你开始——我读到档案,分立线,把脚ing改成真:

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.


问题回答

暂无回答




相关问题
How can I load a folders files into a ListView?

I d like to have a user select a folder with the FolderBrowserDialog and have the files loaded into the ListView. My intention is to make a little playlist of sorts so I have to modify a couple of ...

File Handling Issue

I am developing a tool in c#, at one instance I start writing into a xml file continuously using my tool,when i suddenly restart my machine the particular xml file gets corrupted, what is the reason ...

C# GemBox Excel Import Error

I am trying to import an excel file into a data table using GemBox and I keep getting this error: Invalid data value when extracting to DataTable at SourceRowIndex: 1, and SourceColumnIndex: 1. As ...

Saving output of a for-loop to file

I have opened a file with blast results and printed out the hits in fasta format to the screen. The code looks like this: result_handle = open("/Users/jonbra/Desktop/my_blast.xml") from Bio.Blast ...

热门标签