Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #pragma hdrstop
- #include "Unit1.h"
- int n = 1, m = 3;
- int **a;
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma resource "*.dfm"
- TForm1 *Form1;
- //---------------------------------------------------------------------------
- __fastcall TForm1::TForm1(TComponent* Owner)
- : TForm(Owner)
- {
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::FormCreate(TObject *Sender)
- {
- Edit1->Text=IntToStr(n);
- Edit2->Text=IntToStr(m);
- StringGrid1->ColCount = m+1;
- StringGrid1->RowCount = n+1;
- StringGrid1->Cells[0][0] = "Ìàòðèöà A";
- for(int i=1; i<=n;i++){
- StringGrid1->Cells[0][i]="i="+IntToStr(i);}
- for(int i=1; i<=m;i++){
- StringGrid1->Cells[i][0]="j="+IntToStr(i);}
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Edit1Change(TObject *Sender)
- {
- int i;
- n=StrToInt(Edit1->Text);
- StringGrid1->RowCount = n+1;
- for(i=1; i<=n;i++){
- StringGrid1->Cells[0][i]="i="+IntToStr(i);}
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Edit2Change(TObject *Sender)
- {
- int i;
- m=StrToInt(Edit2->Text);
- StringGrid1->ColCount = m+1;
- for(i=1; i<=m;i++){
- StringGrid1->Cells[i][0]="j="+IntToStr(i);}
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Button1Click(TObject *Sender)
- {
- int j, i, s=0;
- n=StrToInt(Edit1->Text);
- if(n<1){
- ShowMessage("Fail! Ñòðîêè");
- return;}
- m=StrToInt(Edit2->Text);
- if(m<3){
- ShowMessage("Fail! Ñòîëáöû");
- return;}
- a = new int* [n];
- for(i=0; i<n; i++)
- a[i] = new int [m];
- for(i=1; i<n;i++){
- for(j=1; j<m;j++)
- a[i][j]=StrToInt(StringGrid1->Cells[i][j]);}
- for(i=0; i<n;i++){
- for(j=0; j<m;j++)
- if(a[i][j]>a[i][j+1] && a[i][j+1]>a[i][j+2]) s++;}
- Label3->Caption="Ðåçóëüòàò = "+IntToStr(s);
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Button2Click(TObject *Sender)
- {
- delete []a;
- ShowMessage("del");
- Close();
- }
- //---------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment