Программа для построения БЛОК-СХЕМ!!!
Вычесление эл-тов матрицы С={cij} являющейся суммой матри - Бесплатно сделаю блок-схему
Меню сайта

Форма входа

Друзья сайта

  • Программа Ростовщик 1.04

  • Программа расчета кредита

  • Курсовые по информатике

  • Старый, но живой ГОСТ для Блок-Схем

  • Сервис заполнения бланков аттестатов

  • Библиотека VBA для сервиса AntiGate.com

  • Статистика

    Locations of visitors to this page

    Приветствую Вас, Гость · RSS 09.10.2026, 13:50

    [ Новые сообщения · Участники · Правила форума · Поиск · RSS ]
    • Страница 1 из 1
    • 1
    Модератор форума: diamFC  
    Вычесление эл-тов матрицы С={cij} являющейся суммой матри
    MrДата: Воскресенье, 15.04.2012, 16:59 | Сообщение # 1
    Рядовой
    Группа: Пользователи
    Сообщений: 1
    Репутация: 0
    Статус: Offline
    Задача:
    Составить программу для вычесления элементов матрицы С={cij} являющейся суммой матриц A={aij} и B={bij}.Каждый элемент матрицы С вцысисляется по формуле cij=aij+bij i,j=1,2,...n,причем матрица А задана,а элементы матрицы В вычисляются по формуле:
    bij=aij,если aij>=0
    bij=1,если aij<0

    Код программы:
    unit Unit1;

    interface

    uses
    Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
    Dialogs, StdCtrls, Grids, Spin;
    type
    TForm1 = class(TForm)
    StringGrid1: TStringGrid;
    StringGrid2: TStringGrid;
    StringGrid3: TStringGrid;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    CalcButton: TButton;
    RandomButton: TButton;
    ClearButton: TButton;
    SpinEdit1: TSpinEdit;
    Label5: TLabel;
    ButtonB: TButton;
    Label1: TLabel;
    procedure CalcButtonClick(Sender: TObject);
    procedure RandomButtonClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure ClearButtonClick(Sender: TObject);
    procedure SpinEdit1Change(Sender: TObject);
    procedure ButtonBClick(Sender: TObject);
    private
    { Private declarations }
    public
    { Public declarations }
    end;

    var
    Form1: TForm1;

    implementation

    {$R *.dfm}

    procedure TForm1.ButtonBClick(Sender: TObject);
    var
    i,j:word;
    begin
    for i := 0 to SpinEdit1.Value-1 do
    for j := 0 to SpinEdit1.Value-1 do
    if StrTOFLoat(StringGrid1.Cells[i,j])<0
    then StringGrid2.Cells[i,j]:=FloatToSTr(1)
    else StringGrid2.Cells[i,j]:=StringGrid1.Cells[i,j];
    end;

    procedure TForm1.CalcButtonClick(Sender: TObject);
    var i,j:Integer;
    begin
    if (stringgrid1.Cells[0,0]='') or (stringgrid2.Cells[SpinEdit1.Value-1,SpinEdit1.Value-1]='') then
    begin
    Messagebox(handle,'Заполните матрицы А и Б','Внимание',MB_OK+MB_IconInformation);
    exit;
    end;
    for i:=0 to SpinEdit1.Value-1 do
    for j:=0 to SpinEdit1.Value-1 do
    stringgrid3.Cells[i,j]:=FloatToSTr(StrTOFLoat(stringgrid1.Cells[i,j])+StrTOFLoat(stringgrid2.Cells[i,j]));
    end;

    procedure TForm1.ClearButtonClick(Sender: TObject);
    var
    i,j:word;
    begin
    for i := 0 to SpinEdit1.Value-1 do
    for j := 0 to SpinEdit1.Value-1 do
    begin
    StringGrid1.Cells[i,j]:='';
    StringGrid2.Cells[i,j]:='';
    StringGrid3.Cells[i,j]:='';
    end;
    end;

    procedure TForm1.FormCreate(Sender: TObject);
    begin
    Form1.Left:=(Screen.Width-Form1.Width) div 2;
    Form1.Top:=(Screen.Height-Form1.Height) div 2;
    end;

    procedure TForm1.RandomButtonClick(Sender: TObject);
    var
    i,j:word;
    begin
    randomize;
    for i := 0 to SpinEdit1.Value-1 do
    for j := 0 to SpinEdit1.Value-1 do
    StringGrid1.Cells[i,j]:=FloatToSTr(random(21)-10);
    end;

    procedure TForm1.SpinEdit1Change(Sender: TObject);
    begin
    ClearButton.Click;
    StringGrid1.ColCount:=SpinEdit1.Value;
    StringGrid1.RowCount:=SpinEdit1.Value;
    StringGrid2.ColCount:=SpinEdit1.Value;
    StringGrid2.RowCount:=SpinEdit1.Value;
    StringGrid3.ColCount:=SpinEdit1.Value;
    StringGrid3.RowCount:=SpinEdit1.Value;
    end;

    end.

    Зарание блогодарен!
     
    diamFCДата: Воскресенье, 15.04.2012, 17:18 | Сообщение # 2
    Полковник
    Группа: Администраторы
    Сообщений: 207
    Репутация: 11
    Статус: Offline

    Сделана с помощью программы DiamFC
    Прикрепления: 1522092.zip (161.2 Kb) · 2464822.jpg (40.9 Kb)
     
    • Страница 1 из 1
    • 1
    Поиск:

    Copyright MyCorp © 2026
    Конструктор сайтов — uCoz