Технический форум

Технический форум (http://www.tehnari.ru/)
-   Delphi, Kylix and Pascal (http://www.tehnari.ru/f43/)
-   -   Не выводит массив Delphi7 (http://www.tehnari.ru/f43/t52001/)

student. 21.05.2011 15:32

Не выводит массив Delphi7
 
Вложений: 1
Помогите пожалуйста с задачкой:

Дана матрица размером NxM. Упорядочить её строки по возрастанию их наибольших элементов.

В проге невыводит массив в ответ... гляньте в чём проблема

вот прога: Вложение 38544

Warko 19.11.2013 20:23

тоже нужна эта задача

Warko 19.11.2013 21:27

Помогите кто может=)

Gruvi 19.11.2013 21:43

Вот вам программа, пользуйтесь.

Цитата:

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Grids;

type
TForm1 = class(TForm)
Edit1: TEdit;
Label1: TLabel;
StringGrid1: TStringGrid;
Button1: TButton;
StringGrid2: TStringGrid;
Label2: TLabel;
Edit2: TEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var b:array of array of integer;
n,m,i,j,k,x:integer;
begin
randomize;
if not TryStrToInt(Edit1.Text,n)
or (StrToInt(Edit1.Text)<1) then
begin
ShowMessage('Количество строк введено неверно, повторите ввод');
Edit1.Clear;
Edit1.SetFocus;
exit
end;
n:=StrToInt(Edit1.Text);
if not TryStrToInt(Edit2.Text,m)
or (StrToInt(Edit2.Text)<1) then
begin
ShowMessage('Количество столбцов введено неверно, повторите ввод');
Edit2.Clear;
Edit2.SetFocus;
exit
end;
m:=StrToInt(Edit2.Text);
StringGrid1.ColCount:=m;
StringGrid1.RowCount:=n;
StringGrid2.ColCount:=m;
StringGrid2.RowCount:=n;
setlength(b,n,m);
for i:=0 to n-1 do
for j:=0 to m-1 do
begin
b[i,j]:=random(100);
StringGrid1.Cells[j,i]:=IntToStr(b[i,j]);
end;
for j:=0 to m-1 do
for i:=0 to n-2 do
for k:=i+1 to n-1 do
if b[i,j]>b[k,j] then
begin
x:=b[i,j];
b[i,j]:=b[k,j];
b[k,j]:=x
end;
for i:=0 to n-1 do
for j:=0 to m-1 do
StringGrid2.Cells[j,i]:=IntToStr(b[i,j])
end;

Warko 19.11.2013 21:54

Большое спасибо выручил, все отлично работает + реп :D


Часовой пояс GMT +4, время: 03:32.

Powered by vBulletin® Version 4.5.3
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.