Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 04-30-2018, 09:45 AM
Gromopetr Gromopetr is offline
Junior Member
 
Join Date: Apr 2018
Posts: 3
Default me very really need help with matrix programming. help me please

HELP!!!
Ok, I need to develop an algorythm, code and the interface for an electronic package, who will enter the matrix nxm in random numbers from 0 to 55 and who will find the minimum and the maximum as numbers.
Need to be writen in a form.
Thank you very much!!!

Last edited by Gromopetr; 04-30-2018 at 04:08 PM.
Reply With Quote
  #2  
Old 04-30-2018, 11:37 AM
Norrit Norrit is offline
Moderator
 
Join Date: Aug 2001
Location: Landgraaf
Posts: 7,305
Default

We love school assignments...

What have you got so far and what are the problems you encounter?
Not sure how you get your "electronic package" and what "matrix mxn" is, so perhaps if you provide what you've got so far it will become more understandable
Reply With Quote
  #3  
Old 04-30-2018, 03:37 PM
Gromopetr Gromopetr is offline
Junior Member
 
Join Date: Apr 2018
Posts: 3
Default

Quote:
Originally Posted by Norrit View Post
We love school assignments...

What have you got so far and what are the problems you encounter?
Not sure how you get your "electronic package" and what "matrix mxn" is, so perhaps if you provide what you've got so far it will become more understandable
I have an example of a similar job written with errors in the design


Unit Rab_4;

Interface

Uses

Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,

StdCtrls, ExtCtrls, Grids;

type

TInputForm = class(TForm)

StringGrid1: TStringGrid;

StringGrid2: TStringGrid;

StringGrid3: TStringGrid;

Label1: TLabel;

Edit1: TEdit;

Button1: TButton;

Button2: TButton;

Procedure FormCreate(Sender: TObject);

Procedure Button1Click(Sender: TObject);

Procedure Button2Click(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

const

Nmax = 10; // The maximum dimension of an array

type

Mas1 = array[1..Nmax] of Extended; // Declaring the type of a one-dimensional array

Mas2 = array[1..Nmax, 1..Nmax] of Extended; // Declaring the type of a two-dimensional array

var

InputForm: TInputForm;

A : Mas2; // Declaring a two-dimensional array

B, Y : Mas1; // Declaring one-dimensional arrays

N, i, j : integer;

Implementation

{$R *.DFM}

Procedure TInputForm.FormCreate(Sender: TObject);

begin

N := 3; // Array Dimension

Edit1.Text := FloatToStr(N);

// Specifying the number of rows and columns

StringGrid1.ColCount := N + 1;

StringGrid1.RowCount := N + 1;

StringGrid2.RowCount := N + 1;

StringGrid3.RowCount := N + 1;

// Enter the name of the array in the upper left cell of the table

StringGrid1.Cells[0, 0] := 'Массив A';

StringGrid2.Cells[0, 0] := 'Массив B';

StringGrid3.Cells[0, 0] := 'Массив Y';

// Filling of the upper and left columns with explanatory inscriptions

for i:=1 to N do

begin

StringGrid1.Cells[0, i] := 'i='+ IntToStr(i);

StringGrid1.Cells[i, 0] := 'j='+ IntToStr(i);

end;

end;

Procedure TInputForm.Button1Click(Sender: TObject);

begin

N := StrToInt(Edit1.Text);

// Specifying the Number of Rows and Columns in Tables

StringGrid1.ColCount := N + 1;

StringGrid1.RowCount := N + 1;

StringGrid2.RowCount := N + 1;

StringGrid3.RowCount := N + 1;

// Filling of the upper and left columns with explanatory inscriptions

for i:=1 to N do

begin

StringGrid1.Cells[0, i] := 'i=' + IntToStr(i);

StringGrid1.Cells[i, 0] := 'j=' + IntToStr(i);

end;

end;



Procedure TInputForm.Button2Click(Sender: TObject);

var

s : extended;

begin

// Filling an array A with elements from a table StringGrid1

for i:=1 to N do

for j:=1 to N do

A[i, j] := StrToFloat(StringGrid1.Cells[j, i]);

// Filling an array B with elements from a table StringGrid2

for i:=1 to N do

B[i] := StrToFloat(StringGrid2.Cells[0, i]);

// Multiplication of array A by array B

for i:=1 to N do

begin

s := 0;

for j:=1 to N do

s := s + A[i, j]*B[j];

Y[i] := s;

// outputting the result to a table StringGrid3

StringGrid3.Cells[0, i] := FloatToStrF(Y[i], ffFixed,6,2);

end;

end;

end.
Reply With Quote
  #4  
Old 05-01-2018, 07:24 AM
Norrit Norrit is offline
Moderator
 
Join Date: Aug 2001
Location: Landgraaf
Posts: 7,305
Default

A nice piece of code, but what are the problems in this, what are the parts that don't work as expected?

And naming conventions are a must, ButtonX, StringGridX, what are it's purposes?

As for the min and max value of an Array I would take a look at the Math unit (just add Math to the uses).
It has MinIntValue and MaxIntValue already implemented.
Reply With Quote
  #5  
Old 05-02-2018, 04:40 PM
Gromopetr Gromopetr is offline
Junior Member
 
Join Date: Apr 2018
Posts: 3
Default Matrix help

The problem is that I do not understand how to write it
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT. The time now is 02:45 PM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2018, vBulletin Solutions, Inc.