Форумчанин
Регистрация: 26.10.2007
Сообщений: 124
|
Нужно переделать код с Delphi на C++ Builder
Ребят, есть программа для работы с матрицами написанная на Delphi, её код необходимо переделать чтоб она работала на C++ Builder 6.
Вот код приложения на Delphi начиная с раздела глобальных переменных:
Код:
var
n,A_r,A_c,B_r,B_c:integer;
Form1: TForm1;
implementation
uses Unit2;
{$R *.dfm}
procedure TForm1.Timer1Timer(Sender: TObject);
StatusBar1.Panels[0].Text:='Ìàòðèöà ñ èñïîëüçîâàíèåì StringGrid';
StatusBar1.Panels[1].Text:=Timetostr(time);
StatusBar1.Panels[2].Text:='Áåëåâ Â.Þ, Æàáèí Ï.À';
end;
procedure TForm1.Button1Click(Sender: TObject);
var s:string;
begin
s:=edit5.text;
B_r:=StrToInt(Copy(S,1,Pos(',',s)-1));
B_c:=StrToInt(Copy(S,Pos(',',s)+1,Length(s)));
StringGrid2.ColCount:=B_c;
StringGrid2.RowCount:=B_r;
StringGrid2.height:=B_r*StringGrid1.DefaultRowHeight+10;
StringGrid2.Width:=B_c*StringGrid1.DefaultColWidth+10;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
close;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
close;
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
AboutBox.show;
end;
procedure TForm1.Button5Click(Sender: TObject);
AboutBox.Show;
end;
procedure TForm1.Button6Click(Sender: TObject);
begin
AboutBox.Show;
end;
procedure TForm1.Timer2Timer(Sender: TObject);
begin
StatusBar2.Panels[0].Text:='Ìàòðèöà ñ èñïîëüçîâàíèåì Memo';
StatusBar2.Panels[1].Text:=Timetostr(time);
StatusBar2.Panels[2].Text:='Áåëåâ Â.Þ, Æàáèí Ï.À';
end;
procedure TForm1.Timer3Timer(Sender: TObject);
begin
StatusBar3.Panels[0].Text:='Ìàòðèöà ñ çàãðóçêîé èç ôàéëà';
StatusBar3.Panels[1].Text:=Timetostr(time);
StatusBar3.Panels[2].Text:='Áåëåâ Â.Þ, Æàáèí Ï.À';
end;
procedure TForm1.Button7Click(Sender: TObject);
var s:string;
begin
s:=edit1.text;
A_r:=StrToInt(Copy(S,1,Pos(',',s)-1));
A_c:=StrToInt(Copy(S,Pos(',',s)+1,Length(s)));
B_r:=A_c;
StringGrid1.ColCount:=A_c;
StringGrid1.RowCount:=A_r;
StringGrid1.height:=A_r*StringGrid1.DefaultRowHeight+10;
StringGrid1.Width:=A_c*StringGrid1.DefaultColWidth+10;
end;
procedure TForm1.Button8Click(Sender: TObject);
var
i,j,ad,s,k:integer;
begin
for i:=0 to A_r-1 do
for j:=0 to A_c-1 do
begin
ad:=0;
for k := 0 to B_r-1 do
ad:=ad+strtoint(StringGrid1.Cells[k,i]) * strtoint(StringGrid2.Cells[j,k]);
StringGrid3.ColCount:=ad;
StringGrid3.RowCount:=ad;
StringGrid3.height:=ad*StringGrid1.DefaultRowHeight+10;
StringGrid3.Width:=ad*StringGrid1.DefaultColWidth+10;
StringGrid3.Cells[j,i]:=Inttostr(ad);
end;
end;
procedure TForm1.Button9Click(Sender: TObject);
var
a:array [1..10,1..10] of integer;
b:array [1..10,1..10] of integer;
i,j,i1,j1,k,k1,rez,l,i2,j2,A_r,A_c,B_r,B_c:integer;
str,s,s1:string;
begin
Memo3.Clear;
s:=Edit2.Text;
A_r:=StrToInt(Copy(S,1,Pos(',',s)-1));
A_c:=StrToInt(Copy(S,Pos(',',s)+1,Length(s)));
B_r:=A_c;
s:=Edit6.Text;
B_c:=StrToInt(Copy(S,Pos(',',s)+1,Length(s)));
for i := 1 to A_r do
begin
s:=Memo1.Lines.Strings[i-1];
if s[Length(s)]<>' ' then s:=s+' ';
for j := 1 to A_c do
begin
s1:=Copy(s,1,Pos(' ',s)-1);
a[i,j]:=StrToInt(s1);
delete(s,1,Length(s1)+1);
end;
end;
for i := 1 to B_r do
begin
s:=Memo4.Lines.Strings[i-1];
if s[Length(s)]<>' ' then s:=s+' ';
for j := 1 to B_c do
begin
s1:=Copy(s,1,Pos(' ',s)-1);
b[i,j]:=StrToInt(s1);
delete(s,1,Length(s1)+1);
end;
end;
S:='';
for i := 1 to A_r do
begin
for j := 1 to B_c do
begin
rez:=0;
for k := 1 to B_r do
rez:=rez+a[i][k]*b[k][j];
s:=s+IntToStr(rez)+' ';
end;
Memo3.Lines.Add(s);
s:='';
end;
end;
procedure TForm1.Button10Click(Sender: TObject);
var
i,j,k,rez,X,Y :Integer;
s,s1:string;
f,f1:textFile;
a:array [1..10,1..10] of integer;
b:array [1..10,1..10] of integer;
begin
Memo2.Clear;
Memo6.Clear;
Memo2.Lines.LoadFromFile(Edit3.Text);
Memo5.Clear;
Memo5.Lines.LoadFromFile(Edit7.Text);
s:=Edit4.Text;
A_r:=StrToInt(Copy(S,1,Pos(',',s)-1));
A_c:=StrToInt(Copy(S,Pos(',',s)+1,Length(s)));
B_r:=A_c;
s:=Edit8.Text;
B_c:=StrToInt(Copy(S,Pos(',',s)+1,Length(s)));
for i := 1 to A_r do
begin
s:=Memo2.Lines.Strings[i-1];
if s[Length(s)]<>' ' then s:=s+' ';
for j := 1 to A_c do
begin
s1:=Copy(s,1,Pos(' ',s)-1);
a[i,j]:=StrToInt(s1);
delete(s,1,Length(s1)+1);
end;
end;
for i := 1 to B_r do
begin
s:=Memo5.Lines.Strings[i-1];
if s[Length(s)]<>' ' then s:=s+' ';
for j := 1 to B_c do
begin
s1:=Copy(s,1,Pos(' ',s)-1);
b[i,j]:=StrToInt(s1);
delete(s,1,Length(s1)+1);
end;
end;S:='';
for i := 1 to A_r do
begin
for j := 1 to B_c do
begin
rez:=0;
for k := 1 to B_r do
rez:=rez+a[i][k]*b[k][j];
s:=s+IntToStr(rez)+' ';
end;
Memo6.Lines.Add(s);
s:='';
end;
end;
end.
Ребят, пожалуйста помогите
|