Всем привет. Помогите кто сможет, нужно перевести код с делфи на C++Builder 6
Код | unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Grids; type TForm1 = class(TForm) sg1: TStringGrid; sg2: TStringGrid; edCol: TEdit; edRow: TEdit; Label1: TLabel; Label2: TLabel; btStr: TButton; btBgn: TButton; procedure btBgnClick(Sender: TObject); procedure btStrClick(Sender: TObject); procedure Poisk(var a:Integer); private { Private declarations } public { Public declarations } end; var Form1: TForm1; n,m: Integer; //столбцы, строки implementation {$R *.dfm} procedure TForm1.btBgnClick(Sender: TObject); //подготовка таблиц и заполнение 1-й var i,j: Integer; begin n:=strtoint(edCol.Text); m:=strtoint(edRow.Text); sg1.ColCount:=n; //столбцы sg1.RowCount:=m; //строки sg2.ColCount:=n; //столбцы randomize; for i:= 0 to n-1 do //столбцы for j:= 0 to m-1 do //строки sg1.Cells[i,j]:=inttostr(random(100)-50); end; procedure TForm1.btStrClick(Sender: TObject); //перебор столбцов var i: Integer; begin for i:= 0 to n-1 do //столбцы Poisk(i); end; procedure TForm1.Poisk(var a:Integer); //обработка в столбце var j: Integer; begin for j:= m-1 downto 0 do //строки if StrToInt(sg1.Cells[a,j])<0 then begin sg2.Cells[a,0]:= sg1.Cells[a,j]; exit; end else sg2.Cells[a,0]:= '0'; end; end.
|
а вот само задание:
Задача состоит в том что надо создать 2-ухмерный массив в стринггрид.(размеры массива вводишь сам, числа рандомные от -50 до 20) Потом нужно чтоб из каждого столбца было выбрано последнее отрицательное число и было занесеноо в следущую стринггрид и получить 1-номерный массив(только из отрицательных чисел). |