Endil

Untitled

Nov 26th, 2014
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.54 KB | None | 0 0
  1. //---------------------------------------------------------------------------
  2.  
  3. #include <vcl.h>
  4. #pragma hdrstop
  5.  
  6. #include "Unit1.h"
  7. int n = 1, m = 3;
  8. int **a;
  9. //---------------------------------------------------------------------------
  10. #pragma package(smart_init)
  11. #pragma resource "*.dfm"
  12. TForm1 *Form1;
  13. //---------------------------------------------------------------------------
  14. __fastcall TForm1::TForm1(TComponent* Owner)
  15.         : TForm(Owner)
  16. {
  17. }
  18. //---------------------------------------------------------------------------
  19.  
  20. void __fastcall TForm1::FormCreate(TObject *Sender)
  21. {
  22.         Edit1->Text=IntToStr(n);
  23.         Edit2->Text=IntToStr(m);
  24.         StringGrid1->ColCount = m+1;
  25.         StringGrid1->RowCount = n+1;
  26.         StringGrid1->Cells[0][0] = "Ìàòðèöà A";
  27.         for(int i=1; i<=n;i++){
  28.             StringGrid1->Cells[0][i]="i="+IntToStr(i);}
  29.         for(int i=1; i<=m;i++){
  30.             StringGrid1->Cells[i][0]="j="+IntToStr(i);}
  31. }
  32. //---------------------------------------------------------------------------
  33. void __fastcall TForm1::Edit1Change(TObject *Sender)
  34. {
  35.     int i;
  36.         n=StrToInt(Edit1->Text);
  37.         StringGrid1->RowCount = n+1;
  38.     for(i=1; i<=n;i++){
  39.                 StringGrid1->Cells[0][i]="i="+IntToStr(i);}
  40. }
  41. //---------------------------------------------------------------------------
  42. void __fastcall TForm1::Edit2Change(TObject *Sender)
  43. {
  44.     int i;
  45.         m=StrToInt(Edit2->Text);
  46.         StringGrid1->ColCount = m+1;
  47.     for(i=1; i<=m;i++){
  48.                 StringGrid1->Cells[i][0]="j="+IntToStr(i);}
  49. }
  50. //---------------------------------------------------------------------------
  51. void __fastcall TForm1::Button1Click(TObject *Sender)
  52. {
  53.     int j, i, s=0;
  54.     n=StrToInt(Edit1->Text);
  55.         if(n<1){
  56.         ShowMessage("Fail! Ñòðîêè");
  57.             return;}
  58.     m=StrToInt(Edit2->Text);
  59.         if(m<3){
  60.                 ShowMessage("Fail! Ñòîëáöû");
  61.             return;}
  62.     a = new int* [n];
  63.     for(i=0; i<n; i++)
  64.         a[i] = new int [m];
  65.         for(i=1; i<n;i++){
  66.                 for(j=1; j<m;j++)
  67.                         a[i][j]=StrToInt(StringGrid1->Cells[i][j]);}
  68.     for(i=0; i<n;i++){
  69.             for(j=0; j<m;j++)
  70.                     if(a[i][j]>a[i][j+1] && a[i][j+1]>a[i][j+2]) s++;}
  71.     Label3->Caption="Ðåçóëüòàò = "+IntToStr(s);
  72. }
  73. //---------------------------------------------------------------------------
  74. void __fastcall TForm1::Button2Click(TObject *Sender)
  75. {
  76.     delete []a;
  77.     ShowMessage("del");
  78.     Close();
  79. }
  80. //---------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment