Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
14
Добавлен:
28.06.2014
Размер:
7.77 Кб
Скачать
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
char EnterWord[20];
char ExitWord[20];
char MassPereh[3][5];
char MassVih[3][5];
char SostWord[20];
char vek[10];
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
   StG1->Cells[0][1]="a";
   StG1->Cells[0][2]="b";
   StG1->Cells[0][3]="c";
   StG2->Cells[0][1]="a";
   StG2->Cells[0][2]="b";
   StG2->Cells[0][3]="c";
   StG1->Cells[1][0]="0";
   StG1->Cells[2][0]="1";
   StG1->Cells[3][0]="2";
   StG1->Cells[4][0]="3";
   StG1->Cells[5][0]="4";
   StG2->Cells[1][0]="0";
   StG2->Cells[2][0]="1";
   StG2->Cells[3][0]="2";
   StG2->Cells[4][0]="3";
   StG2->Cells[5][0]="4";
}
//---------------------------------------------------------------------------

void __fastcall TForm1::N5Click(TObject *Sender)
{
  Application->Terminate();
}
//---------------------------------------------------------------------------



void __fastcall TForm1::N3Click(TObject *Sender)
{
 char c; //начальное сотояние
  int i;
  int j;

  for(i=1;i<StG1->RowCount;i++)
    for (j=1;j<StG1->ColCount;j++)
    {
      strcpy(vek,StG1->Cells[j][i].c_str());
      MassPereh[i-1][j-1]=vek[0];
      strcpy(vek,StG2->Cells[j][i].c_str());
      MassVih[i-1][j-1]=vek[0];
     }
  if (Edit1->Text=="") c='0';
  else
  {
   if (Edit1->Text=='0') c='0';
   if (Edit1->Text=='1') c='1';
   if (Edit1->Text=='2') c='2';
   if (Edit1->Text=='3') c='3';
   if (Edit1->Text=='4') c='4'; 
  }
   for (i=0;(i<20)&&(StG3->Cells[i][0]!="");i++)
    {
      strcpy(&EnterWord[i],StG3->Cells[i][0].c_str());
     }
  int k=i;

  bool fl=true;
  for(i=0;i<k;i++)
  {
   if (fl)
    SostWord[i]=c;
    fl=false;
    switch(EnterWord[i])
    { case'a':
              { switch(c)
                 { case'0':
                       {   ExitWord[i]=MassVih[0][0];
                           c=MassPereh[0][0];fl=true;
                           break;
                       }
                   case'1':
                       {   ExitWord[i]=MassVih[0][1];
                           c=MassPereh[0][1];fl=true;
                           break;
                       }
                   case'2':
                       {   ExitWord[i]=MassVih[0][2];
                           c=MassPereh[0][2];fl=true;
                           break;
                       }
                   case'3':
                       {   ExitWord[i]=MassVih[0][3];
                           c=MassPereh[0][3];fl=true;
                           break;
                       }
                   case'4':
                       {   ExitWord[i]=MassVih[0][4];
                           c=MassPereh[0][4];fl=true;
                           break;
                       }
                  }
                break;
              }
      case'b':
              { switch(c)
                 { case'0':
                       {   ExitWord[i]=MassVih[1][0];
                           c=MassPereh[1][0];fl=true;
                           break;
                       }
                   case'1':
                       {   ExitWord[i]=MassVih[1][1];
                           c=MassPereh[1][1];fl=true;
                           break;
                       }
                   case'2':
                       {   ExitWord[i]=MassVih[1][2];
                           c=MassPereh[1][2];fl=true;
                           break;
                       }
                   case'3':
                       {   ExitWord[i]=MassVih[1][3];
                           c=MassPereh[1][3];fl=true;
                           break;
                       }
                   case'4':
                       {   ExitWord[i]=MassVih[1][4];
                           c=MassPereh[1][4];fl=true;
                           break;
                       }
                  }
                break;
              }
      case'c':
              { switch(c)
                 { case'0':
                       {   ExitWord[i]=MassVih[2][0];
                           c=MassPereh[2][0];fl=true;
                           break;
                       }
                   case'1':
                       {   ExitWord[i]=MassVih[2][1];
                           c=MassPereh[2][1];fl=true;
                           break;
                       }
                   case'2':
                       {   ExitWord[i]=MassVih[2][2];
                           c=MassPereh[2][2];fl=true;
                           break;
                       }
                   case'3':
                       {   ExitWord[i]=MassVih[2][3];
                           c=MassPereh[2][3];fl=true;
                           break;
                       }
                   case'4':
                       {   ExitWord[i]=MassVih[2][4];
                           c=MassPereh[2][4];fl=true;
                           break;
                       }
                  }
                break;
              }
        }
  }

  for (i=0;i<20;i++)
    {
      //StG3->Cells[i][0]="";
      StG4->Cells[i][0]="";
      StG5->Cells[i][0]="";
     }

  for (i=0;i<k;i++)
     {
       //vek[0]=EnterWord[i];
       //StG3->Cells[i][0]=AnsiString(vek);
       vek[0]=SostWord[i];
       StG4->Cells[i][0]=AnsiString(vek);
       vek[0]=ExitWord[i];
       StG5->Cells[i][0]=AnsiString(vek);
      }
}
//---------------------------------------------------------------------------






void __fastcall TForm1::N22Click(TObject *Sender)
{
 StG1->RowCount=3;
  StG2->RowCount=3;
  StG1->Cells[1][1]="1";StG1->Cells[2][1]="2";StG1->Cells[3][1]="3";StG1->Cells[4][1]="4";StG1->Cells[5][1]="4";
  StG1->Cells[1][2]="1";StG1->Cells[2][2]="0";StG1->Cells[3][2]="1";StG1->Cells[4][2]="2";StG1->Cells[5][2]="3";
  StG2->Cells[1][1]="b";StG2->Cells[2][1]="a";StG2->Cells[3][1]="a";StG2->Cells[4][1]="a";StG2->Cells[5][1]="a";
  StG2->Cells[1][2]="b";StG2->Cells[2][2]="a";StG2->Cells[3][2]="a";StG2->Cells[4][2]="a";StG2->Cells[5][2]="a";
  for (int i=0;i<20;i++)
    {  StG3->Cells[i][0]="";
       StG4->Cells[i][0]="";
       StG5->Cells[i][0]=""; }
  StG3->Cells[0][0]="c";StG3->Cells[1][0]="b";StG3->Cells[2][0]="b";
}
//---------------------------------------------------------------------------

void __fastcall TForm1::N11Click(TObject *Sender)
{
 StG1->RowCount=4;
  StG2->RowCount=4;
  StG1->Cells[1][1]="1";StG1->Cells[2][1]="0";StG1->Cells[3][1]="0";StG1->Cells[4][1]="4";StG1->Cells[5][1]="3";
  StG1->Cells[1][2]="1";StG1->Cells[2][2]="0";StG1->Cells[3][2]="1";StG1->Cells[4][2]="4";StG1->Cells[5][2]="3";
  StG1->Cells[1][3]="1";StG1->Cells[2][3]="0";StG1->Cells[3][3]="1";StG1->Cells[4][3]="4";StG1->Cells[5][3]="3";
  StG2->Cells[1][1]="b";StG2->Cells[2][1]="a";StG2->Cells[3][1]="a";StG2->Cells[4][1]="a";StG2->Cells[5][1]="b";
  StG2->Cells[1][2]="a";StG2->Cells[2][2]="b";StG2->Cells[3][2]="a";StG2->Cells[4][2]="a";StG2->Cells[5][2]="b";
  StG2->Cells[1][3]="a";StG2->Cells[2][3]="b";StG2->Cells[3][3]="a";StG2->Cells[4][3]="a";StG2->Cells[5][3]="b";
  for (int i=0;i<20;i++)
   { StG3->Cells[i][0]="";
     StG4->Cells[i][0]="";
     StG5->Cells[i][0]=""; }
  StG3->Cells[0][0]="c";StG3->Cells[1][0]="b";StG3->Cells[2][0]="b";StG3->Cells[3][0]="b";
}  
//---------------------------------------------------------------------------



Соседние файлы в папке Lrlen4-L
  • #
    28.06.201419.58 Кб14Project1.obj
  • #
    28.06.2014876 б15Project1.res
  • #
    28.06.20142.16 Mб14Project1.tds
  • #
    28.06.20144.23 Кб14Project1.~bpr
  • #
    28.06.20141.27 Кб14Project1.~cpp
  • #
    28.06.20147.77 Кб14Unit1.cpp
  • #
    28.06.201451 б14Unit1.ddp
  • #
    28.06.20146.93 Кб14Unit1.dfm
  • #
    28.06.20141.54 Кб14Unit1.h
  • #
    28.06.2014110.64 Кб15Unit1.obj
  • #
    28.06.20147.77 Кб14Unit1.~cpp