Добавил:
Tushkan
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:Готовые лабораторные работы (ММ) / DMath_lab1 / Unit1
.cpp//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
static const int n = 4;
unsigned count = StringGrid1->RowCount;
typedef Vector1<n> Vector;
NSD::List<Vector> lst;
for(int i = 0; i < count; ++i)
{
lst.getLast().insertAfter(Vector(StringGrid1->Cells[0][i].c_str()));
}
Run(lst);
unsigned resultCount = 0;
for(NSD::List<Vector>::iterator h = lst.getFirst(); h; ++h, ++resultCount);
StringGrid2->RowCount = resultCount;
int i = 0;
for(NSD::List<Vector>::iterator s = lst.getFirst(); s; ++s, ++i)
{
Vector curr = *s;
AnsiString result;
for(unsigned j = 0; j < n; ++j)
{
switch(curr.data_[j])
{
case _null: result += "0"; break;
case _one: result += "1"; break;
case _X: result += "x"; break;
}
}
StringGrid2->Cells[0][i] = result;
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Edit1Change(TObject *Sender)
{
StringGrid1->RowCount = StrToInt(Edit1->Text);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
StringGrid1->Cells[0][0] = "10xx01001xxxx101";
StringGrid1->Cells[0][1] = "0x11x1xx1x00xx01";
StringGrid1->Cells[0][2] = "xxxxxxxxxxxxx01x";
/* StringGrid1->Cells[0][0] = "001";
StringGrid1->Cells[0][1] = "010";
StringGrid1->Cells[0][2] = "011";
StringGrid1->Cells[0][3] = "100";
StringGrid1->Cells[0][4] = "101";
StringGrid1->Cells[0][5] = "110";
*/
//lst.getLast().insertAfter(Vector("10xx01001xxxx101"));
//lst.getLast().insertAfter(Vector("0x11x1xx1x00xx01"));
//lst.getLast().insertAfter(Vector("xxxxxxxxxxxxx01x"));
}
//---------------------------------------------------------------------------
Соседние файлы в папке DMath_lab1