суббота, 8 декабря 2012 г.

PrintWisdom V1.30.1 ("Blind Judge")

//---------------------------------------------------------------------------

#include
#pragma hdrstop

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;

#define W_COUNT 18846
using namespace std;

struct range {
int a, b;
};

#define MAX_RANGES 18

string RANGE_ID[MAX_RANGES] = {
"My questions",
"Rainbow core",
"Google core",
"Science fiction library",
"Wide screen photo 1",
"Wide screen photo 2",
"Ballads",
"My music",
"Wisdoms",
"Thoughts",
"Blog themes",
"My dreams",
"Alternative blog themes",
"Top 1000",
"Films 1",
"Films 2",
"Actors",
"Russian picture set"
};

char *SoundFiles[MAX_RANGES] = {
"My questions.wav",
"Rainbow core.wav",
"Google core.wav",
"Science fiction library.wav",
"Wide screen photo 1.wav",
"Wide screen photo 2.wav",
"Ballads.wav",
"My music.wav",
"Wisdoms.wav",
"Thoughts.wav",
"Blog themes.wav",
"My dreams.wav",
"Alternative blog themes.wav",
"Top 1000.wav",
"Films 1.wav",
"Films 2.wav",
"Actors.wav",
"Russian picture set.wav"
};

// !327, !1444, !595, !2303, !252, !444,
// !180, !153, !1179, !35, !809, !36, !225, !1000,
// !1340, !1075, !6846, !603

range ranges[MAX_RANGES] = {
{0,326},
{327,1770},
{1771,2365},
{2366,4668},
{4669,4920},
{4921,5364},
{5365,5544},
{5545,5697},
{5698,6876},
{6877,6911},
{6912,7720},
{7721,7756},
{7757,7981},
{7982,8981},
{8982,10321},
{10322,11396},
{11397,18242},
{18243,18845}
};

//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
Edit1->SelectAll();
Edit1->ClearSelection();
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button1Click(TObject *Sender)
{
randomize();
FILE *W = fopen("Wisdom.dat", "rt");
vector Wisdoms;
for (int n=0; n < W_COUNT; n++)
{
char s[8192];
fgets(s, sizeof s, W);
do {
if (s[strlen(s)-1] == 0x0D || s[strlen(s)-1] == 0x0A)
s[strlen(s)-1] = 0;
else break;
} while (true);
Wisdoms.push_back(string(s));
}
fclose(W);
Edit1->SelectAll();
Edit1->ClearSelection();
static char buf[8192];
int ind = rand()%W_COUNT;
strcpy(buf, Wisdoms[ind].c_str());
Edit1->SetSelTextBuf(buf);
int RANGE_NUM = 0;
for (int R=0; R < MAX_RANGES; R++)
{
if (ind >= ranges[R].a && ind <= ranges[R].b)
{
RANGE_NUM = R;
break;
}
}
sndPlaySound(SoundFiles[RANGE_NUM], SND_SYNC);
}
//---------------------------------------------------------------------------

Комментариев нет:

Отправить комментарий