procedure TForm1.N10Click(Sender: TObject); var f:textfile; g,i,x,a,q,w,p,j,u: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 g:=0 to sg1.ColCount-1 do for i:=0 to sg1.RowCount-1 do begin readln(f,s); sg1.Cells[g,i]:= s; end; a:=0; q:=0; w:=0; p:=0; j:=sg1.ColCount-1; for u:=1 to sg1.RowCount-1 do begin if sg1.Cells[j,u]<>'' then x:=strtoint(sg1.cells[j,u]); if x=5 then a:=a+1; if x=4 then q:=q+1; if x=3 then w:=w+1; if x=2 then p:=p+1; end; l1.caption:=l1.Caption+ 'îòë: '+inttostr(a)+chr(10)+ 'õîð: '+inttostr(q)+chr(10)+ 'óäîâë: '+inttostr(w)+chr(10)+ 'íåóä: '+inttostr(p); end;
procedure TForm1.N9Click(Sender: TObject); var f:textfile; r,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; end;
rewrite(f); s:=inttostr(sg1.colcount); writeln(f,s); s:=inttostr(sg1.RowCount); writeln(f,s); for c:=0 to sg1.ColCount-1 do for r:=0 to sg1.RowCount-1 do begin s:=sg1.Cells[c,r]; writeln (f,s); end; closefile(f);