procedure TForm1.N8Click(Sender: TObject); var f:textfile; j,r,x,z,a,i,c:integer; s:string; begin assignfile(f,'c:\qwerty\qwerty2.txt'); reset(f); readln(f,s); sg1.colCount:=strtoint(s); readln(f,s); sg1.rowcount:=strtoint(s); while not eof(f) do for r:=0 to sg1.ColCount-1 do for i:=0 to sg1.RowCount-1 do begin readln(f,s); sg1.Cells[r,i]:= s; end; sg1.ColCount:=sg1.ColCount+1; j:=sg1.colcount-1; sg1.Cells[j,0]:='Èòîã'; z:=0; a:=0; for i:=1 to sg1.rowCount-1 do begin for r:=2 to sg1.ColCount-2 do begin if (sg1.Cells[r,i]<>'í')and (sg1.Cells[r,i]<>' ')and(sg1.Cells[r,i]<>'') then begin x:=strtoint(sg1.cells[r,i]); z:=z+x; a:=a+1; end; end; if a<>0 then sg1.Cells[r,i]:=inttostr(z div a); z:=0; a:=0; end; closefile(f); rewrite(f); s:=inttostr(sg1.colcount); writeln(f,s); s:=inttos
... Читать дальше »
procedure TForm1.N7Click(Sender: TObject); var f:textfile; j,r,x,z,a,i:integer; s:string; begin assignfile(f,'c:\qwerty\qwerty2.txt'); reset(f); readln(f,s); sg1.colCount:=strtoint(s); readln(f,s); sg1.rowcount:=strtoint(s); while not eof(f) do for r:=0 to sg1.ColCount-1 do for i:=0 to sg1.RowCount-1 do begin readln(f,s); sg1.Cells[r,i]:= s; end; sg1.ColCount:=sg1.ColCount+1; j:=sg1.colcount-1; sg1.Cells[j,0]:='Èòîã'; z:=0; a:=0; for i:=1 to sg1.rowCount-1 do begin for r:=2 to sg1.ColCount-2 do begin if (sg1.Cells[r,i]<>'í')and (sg1.Cells[r,i]<>' ')and(sg1.Cells[r,i]<>'') then begin x:=strtoint(sg1.cells[r,i]); z:=z+x; a:=a+1; end; end; sg1.Cells[r,i]:=inttostr(z div a); z:=0; a:=0; end; end;