deleted

deletedfwfwfwfwfwgwgweg qgreqgre wgqreg qg qg

Comments

  • : [code]: 5
    : dave
    : laura
    : owen
    : vick
    : amr
    : dave
    : 200 3
    : laura
    : owen
    : vick
    : owen
    : 500 1
    : dave
    : amr
    : 150 2
    : vick
    : owen
    : laura
    : 0 2
    : amr
    : vick
    : vick
    : 0 0[/code]:
    :
    : This is the kind of file i have to read in.
    :
    : Line 1: The single integer, NP
    : Lines 2..NP+1: Each line contains the name of a group member
    : Lines NP+2..end: NP groups of lines organized like this:
    : The first line in the group tells the person's name who will be
    : giving gifts.
    : The second line in the group contains two numbers: The initial
    : amount of money (in the range 0..2000) to be divided up into gifts
    : by the giver and then the number of people to whom the giver will
    : give gifts, NGi (0 = NGi = NP-1).
    : If NGi is nonzero, each of the next NGi lines lists the the name of
    : a recipient of a gift.
    :
    : -----
    : I've tried to read do it with a lot of "For" loops.. But it just
    : gets stacked up.. So some advice on how should i do it?
    :
    [code][color=Blue]const file_name='test.txt';
    delend=#8#8#32;crlf=#13#10;

    var f:text;i,j,k,l,m:word;s:string[40];


    begin
    assign(f,file_name);
    writeln('Opening: ',file_name,crlf);
    {$I-}reset(f);
    if ioresult=0 then begin
    readln(f,i); write(i,' names found: ');
    for j:=1 to i do begin
    readln(f,s);write(s,', ');
    end;writeln(delend,crlf);
    for j:=1 to i do begin
    readln(f,s);readln(f,m,k);
    if k=0 then writeln(s,' gives no gifts') else begin
    write(s,' gives ',m,' worth of gifts to: ');
    for l:=1 to k do begin readln(f,s);write(s,', ');end;writeln(delend);
    end;end;end else writeln(file_name,' not found !');
    close(f);readln;
    end.
    [/color][/code]
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

In this Discussion