read a text file

please help me!!
i want to read a text file which has two lines. the first line has a number that says how many number has the second line. i want to keep the numbers of the second line in order to find the minimum and the maximum. how can i do this? i use pascal...

example of text file
profit.in
10
5 8 9 15 356 69 87 2 4 1


thanks in advance for your help

Comments

  • : please help me!!
    : i want to read a text file which has two lines. the first line has a
    : number that says how many number has the second line. i want to keep
    : the numbers of the second line in order to find the minimum and the
    : maximum. how can i do this? i use pascal...
    :
    : example of text file
    : profit.in
    : 10
    : 5 8 9 15 356 69 87 2 4 1
    :
    "Free soup" today: ;-) [code][blue]{$I-}
    var f:text;
    i,a,b,min,max:word;
    begin
    min:=$ffff;max:=0;
    assign(f,'profit.in');reset(f);
    if ioresult<>0 then writeln('File not found') else begin
    readln(f,a);
    for i:=1 to a do begin
    read(f,b);if bmax then max:=b;
    end;close(f);
    writeln('Minimum=',min,' Maximum=',max);
    end;readln;
    end.[/code]

  • thanks a lot
  • This post has been deleted.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories