rendered paste body//---------------------------------------------------------------------------
#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 TForm1::FailoAnalize()
{
AnsiString Failas2;
if(SaveDialog1->Execute()){
Failas2 = SaveDialog1->FileName;
ofstream fr(Failas2.c_str());
char eil[ilgis], //eilute
eilk[ilgis]; //eilutes kopija
while (fd.get(eil, sizeof eil)){
Memo1->Lines->Add(eil);
strcpy(eilk,eil); // padaro kopija
RastiIlgZodi(eilk);
strcpy(eil + pr, eil + pr + ilg);
fd.ignore();
fr << eil << endl;
}
fr.close();
Memo3->Lines->LoadFromFile(Failas2.c_str());
}
else ShowMessage("Ne isaugota !!");
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
AnsiString Failas;
if(OpenDialog1->Execute()){
Failas = OpenDialog1->FileName;
fd.open(Failas.c_str());
FailoAnalize();
fd.close();
}
else ShowMessage("Failas neatidarytas !!");
}
//---------------------------------------------------------------------------
void TForm1::RastiIlgZodi(char eilk[])
{
pr = -1;
skirt = 0;
ilg = 0;
char *p = strtok(eilk, skyrikliai);
while (p){
TikrintiSuBaziniais(p);
SkaiciuotiSimbolius(p);
if(ar && p && k > skirt){
pr = p - eilk;
skirt = k;
ilg = strlen(p);
}
p = strtok(NULL, skyrikliai);
}
}
//---------------------------------------------------------------------------
void TForm1::NuskaitytiBazinius()
{
ifstream fd("Baziniai.txt");
char beil[ilgis];
while(fd.get(beil, sizeof beil)){
strcpy(beilk, beil);
fd.ignore();
Memo2->Lines->Add(beil);
}
}
//--------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
Close();
}
//---------------------------------------------------------------------------
void TForm1::TikrintiSuBaziniais(char *p)
{
NuskaitytiBazinius();
ar = true;
char *ptr;
ptr = strstr(beilk, p);
if(ptr == NULL){
ar = true;
}
else
ar = false;
}
//---------------------------------------------------------------------------
void TForm1::SkaiciuotiSimbolius(char *p)
{
k = 0;
for(int c = 'A'; c <= 'z'; c++){
if(strchr(p, c)) k++;
}
}
//-----------------