А ЕЖЭ ИО УХА - ШЭЯ!
(ВСЁ ЧТО ПРОИЗНОСИТСЯ БЕЗ ЗУБОВ)
SMS на локальный номер приводить не буду
(там подпись Иван Грозный)
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
class Citizen
{
std::string FullName;
std::string Address;
std::string Phone;
public:
Citizen(std::string arg1, std::string arg2, std::string arg3)
{
FullName = arg1;
Address = arg2;
Phone = arg3;
}
void PrintOut()
{
std::cout << "\nCitizen details:" << std::endl;
std::cout << "====================\n";
std::cout << FullName << std::endl;
std::cout << Address << std::endl;
std::cout << Phone << std::endl;
}
};
void INVOKE_NONSTATIC(Citizen cit)
{
cit.PrintOut();
}
int main()
{
std::vector<Citizen> Flat;
Flat.push_back(Citizen("Aleksandr Derbeev", "Belarus, Gomel, kozhara59_1_10", "+375-023-278-63-58"));
Flat.push_back(Citizen("Galina Derbeeva", "Belarus, Gomel, kozhara59_1_10", "+375-023-278-63-58"));
std::for_each(Flat.begin(), Flat.end(), INVOKE_NONSTATIC);
}
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
bool form_inited = false;
int buflen = 1;
#define WORD_COUNT 17048
#define VOC_PATH "voc.txt"
#define CHAT_PATH "c:\\chat.log"
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Edit1->SetSelTextBuf("");
Edit1->Refresh();
ListBox1->Clear();
using namespace std;
ifstream f(VOC_PATH);
if (!f)
throw -1;
char buf[80];
TObject *A = new mylink();
Button1->Enabled = false;
while (!f.eof())
{
f.getline(buf, sizeof buf);
ListBox1->AddItem(AnsiString(buf), A);
}
ListBox1->Refresh();
form_inited = true;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Add_to_chat(const char *prefix, const char *word)
{
Memo2->Clear();
//char *asctime(const struct tm *tblock);
//struct tm *localtime(const time_t *timer);
//time_t _RTLENTRY _EXPFUNC time(time_t *__timer);
time_t mytimer;
char chatline[1024];
time(&mytimer);
strcpy(chatline, asctime(localtime(&mytimer)));
char c = chatline[strlen(chatline)-1];
if (c == '\r' || c == '\n')
chatline[strlen(chatline)-1] = '\0';
c = chatline[strlen(chatline)-1];
if (c == '\r' || c == '\n')
chatline[strlen(chatline)-1] = '\0';
strcat(chatline, " (");
strcat(chatline, prefix);
strcat(chatline, ")> ");
strcat(chatline, word);
{
const char* mylog = CHAT_PATH;
char *buf = new char[1048576];
strcpy(buf, "");
char temp[1024];
std::ifstream f(mylog);
if (!f)
goto BYPASS;
while (!f.eof())
{
f.getline(temp, sizeof temp);
strcat(buf, temp);
strcat(buf, "\r\n");
}
BYPASS:
strcat(buf, chatline);
strcat(buf, "\r\n");
f.close();
std::ofstream ff(mylog, std::ios::app);
ff.write(chatline, strlen(chatline));
ff.write("\n", 1);
ff.close();
Memo2->SetTextBuf(buf);
buflen = strlen(buf);
Memo2->Refresh();
Memo2->SetFocus();
Memo2->SelStart = buflen-1;
Memo2->SelLength = buflen-1;
delete[] buf;
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Panel1Click(TObject *Sender)
{
if (!form_inited)
return;
int x = (Mouse->CursorPos).x;
int y = (Mouse->CursorPos).y;
unsigned t = (unsigned)clock();
unsigned entropy = (unsigned) (((double)x/y)*1000000);
int pos = (int)((entropy ^ t) % WORD_COUNT);
Memo1->Clear();
Memo1->SetTextBuf(ListBox1->Items->Strings[pos].c_str());
Memo1->Refresh();
Add_to_chat("hiroshima", ListBox1->Items->Strings[pos].c_str());
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
if (!form_inited)
return;
int C = ListBox1->Count;
for (int i=0; i < C; i++)
{
if (ListBox1->Selected[i])
{
Add_to_chat("gradusnik", ListBox1->Items->Strings[i].c_str());
break;
}
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button3Click(TObject *Sender)
{
if (!form_inited)
return;
Edit1->SelectAll();
char buf[4096];
Edit1->GetSelTextBuf(buf, sizeof buf);
Add_to_chat("gradusnik", buf);
Edit1->SetSelTextBuf("");
Edit1->Refresh();
}
//---------------------------------------------------------------------------
std::string last_word = "";
int repeated = 0;
void __fastcall TForm1::Panel1MouseMove(TObject *Sender, TShiftState Shift,
int X, int Y)
{
if (!form_inited)
return;
int x = (Mouse->CursorPos).x;
int y = (Mouse->CursorPos).y;
// if (X % 2 == 1 && Y % 2 == 1)
// return;
int pos = (int)((X * Y) % WORD_COUNT);
/*
if (std::string(ListBox1->Items->Strings[pos].c_str()) == last_word)
repeated++;
else
{
repeated = 0;
}
last_word = std::string(ListBox1->Items->Strings[pos].c_str());
if (repeated < 10)
return;
if (repeated > 10)
return;
*/
Memo1->Clear();
Memo1->SetTextBuf(ListBox1->Items->Strings[pos].c_str());
Memo1->Refresh();
Add_to_chat("hiroshima", ListBox1->Items->Strings[pos].c_str());
}
//---------------------------------------------------------------------------