“Kompyuter injiniringi” fakult ti


,6-tajriba ishining yechilishiga doir masala varianti



Download 0,63 Mb.
Pdf ko'rish
bet21/53
Sana19.09.2021
Hajmi0,63 Mb.
#178300
1   ...   17   18   19   20   21   22   23   24   ...   53
Bog'liq
ushbu uslubiy korsatma telekommunikatsiya texnologiyalari talim yonalishi talabalari uchun moljallangan. (2)

5,6-tajriba ishining yechilishiga doir masala varianti.

Masala: kiruvchi til ; belgisi bilan ajratilgan mantiqiy ifodalardan tashkil topgan, mantiqiy

ifodalar identifikatorlardan tashkil topgan, konstantalar 0 va  1, o’zlashtirish belgisi :q, amal

ishoralari or, xor, not, and va () (4-rasm).



25

5.4-rasm. Masalaning qo’yilishining grafik chizmasi.



Dastur matni

#include

#pragma hdrstop

#include "Unit2.h"

G’G’---------------------------------------------------------------------------

#pragma package(smart_init)

#pragma resource "*.dfm"

TForm2 *Form2;

G’G’---------------------------------------------------------------------------

__fastcall TForm2::TForm2(TComponent* Owner)

: TForm(Owner)

{

SG->Cells[0][0]q"



";

SG->Cells[1][0]q"Znachenie leksemo’";

SG->Cells[2][0]q"Tip leksemo’";

OD->InitialDirqExtractFilePath(Application->ExeName);

SD->InitialDirqExtractFilePath(Application->ExeName);

}

G’G’---------------------------------------------------------------------------




26

void __fastcall TForm2::BitBtn1Click(TObject *Sender)

{if(FileExists(ExtractFilePath(Application->ExeName)Q"Test.txt")qq1) Memo->Lines-

>LoadFromFile(ExtractFilePath(Application->ExeName)Q"Test.txt");

else if (OD->Execute()) Memo->Lines->LoadFromFile(OD->FileName);}

G’G’---------------------------------------------------------------------------

void __fastcall TForm2::BitBtn2Click(TObject *Sender)  {if (SD->Execute())  Memo->Lines-

>SaveToFile(SD->FileName);}

G’G’---------------------------------------------------------------------------

AnsiString KeyWords[]q{"or","xor","and","not"};

AnsiString SI[]q{" ","g’n","g’t",")","(",":",";"};

int *A;


AnsiString ParseString(AnsiString Src,int StP,int &EnP)

 {

  for(int iqStP;i

   for(int jq0;j<7;jQQ)

 if (Src.SubString(i,1)qqSI[j] || Src[i]qq'g’n' || iqqSrc.Length())

 {

 EnPqi;


 if(Src[i]qq'g’n') return Src.SubString(StP,EnP-StP-1);

 else return Src.SubString(StP,EnP-StP);

 }

 }

bool kaq0;



void __fastcall TForm2::GoBtnClick(TObject *Sender)

{

Memo->TextqMemo->TextQ" ";



AnsiString TEMP;int xq0,scq1,ZSq0;

G’G’


 for(int iq1;iText.Length();)

  {


   if(Memo->Text[i]qq'{') {kaq1;iQQ;continue;}

   if(Memo->Text[i]qq'}') {kaq0;iQQ;continue;}

   if(kaqq1) {iQQ;continue;}

   if(int(Memo->Text[i])qq13) {iQQ;continue;}

   if(Memo->Text.SubString(i,2)qq":q")

  {


  SG->Cells[1][sc]qMemo->Text.SubString(i,2);SG->Cells[0][sc]qsc;scQQ;

  SG->RowCountqsc;iQq2;continue;

  }

   TEMPqParseString(Memo->Text,i,x);



   if(x!qi && Memo->Text[i]!q'g’n')

{

 SG->Cells[1][sc]qTEMP; SG->Cells[0][sc]qsc;scQQ;



 SG->RowCountqsc;

  iqx;


  }


27

   else


{

 if(Memo->Text[i]qq'(' || Memo->Text[i]qq')' || Memo->Text[i]qq';' || Memo-

>Text[i]qq':')

  {


  SG->Cells[1][sc]qMemo->Text[i];SG->Cells[0][sc]qsc;scQQ;

  SG->RowCountqsc;

  }

  iQQ;}}


 Aqnew int[SG->RowCount];

  for(int iq1;iRowCount;iQQ)

 {

  if (SG->Cells[1][i]qq"")          {SG->Cells[2][i]q"";goto end;}



 for(int jq0;j<4;jQQ)

if(SG->Cells[1][i]qqKeyWords[j])

 {SG->Cells[2][i]q"Logicheskiy operator ";goto end;}

 if (SG->Cells[1][i]qq":q")          {SG->Cells[2][i]q"Operator prisvaivaniya";goto end;}

 if (SG->Cells[1][i]qq'0' || SG->Cells[1][i]qq'1')

  {SG->Cells[2][i]q"Binarnaya konstanta";goto end;}

 if (SG->Cells[1][i]qq';')        {SG->Cells[2][i]q"Razdelitel";goto end;}

 if (SG->Cells[1][i]qq'(')        {SG->Cells[2][i]q"Otro’vayuhayasya skobka";goto end;}

 if (SG->Cells[1][i]qq')')        {SG->Cells[2][i]q"Zakro’vayuhayasya skobka";goto

end;}


 for(int jq1;jCells[1][i].Length();jQQ)

if((int(SG->Cells[1][i][j])<65 || int(SG->Cells[1][i][j])>90) &&

   (int(SG->Cells[1][i][j])<97 || int(SG->Cells[1][i][j])>122))

{SG->Cells[2][i]q"Nedopustimo’y simvol";A[ZS]qi;ZSQQ;goto

end;}

 SG->Cells[2][i]q"Identifikator";



 end:;

 }

 delete[] A;



}

G’G’---------------------------------------------------------------------------

void __fastcall TForm2::SGDrawCell(TObject *Sender, int ACol, int ARow,

  TRect &Rect, TGridDrawState State)

{

int x,y;


G’G’----------- Poluchenie koordinat dlya vo’voda teksta i sam vo’vod ----------------

 xqRect.leftQ2; G’G’ (Rect.Width()-SG1->Canvas->TextWidth(SG1-

>Cells[ACol][ARow]))G’2;

 yqRect.topQ3;  G’G’(Rect.Height()-SG1->Canvas->TextHeight(SG1-

>Cells[ACol][ARow]))G’2;

 SG->Canvas->Font->ColorqclBlack;

 SG->Canvas->TextOut(x,y,SG->Cells[ACol][ARow]);

G’G’---------------------- Zakraska tekuhey vo’delennoy stroki --------------------




28

if(A!qNULL && ARow!q0)

 for(int iq0;iRowCount;iQQ)

  if(ARowqqA[i])

  {SG->Canvas->Brush->ColorqclRed;SG->Canvas->Font->ColorqclWhite;

   SG->Canvas->FillRect(Rect);

   SG->Canvas->TextOut(x,y,SG->Cells[ACol][ARow]);}

}

Dastur natijasi



Xulosa: Tajriba ishini bajarish natijasida  C++ Builder 7 muxitida dastur matni yozildi


Download 0,63 Mb.

Do'stlaringiz bilan baham:
1   ...   17   18   19   20   21   22   23   24   ...   53




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish