commit a0ad7d896064ca97670006e04d2207d0eeb97476 Author: jdg Date: Sun Sep 12 22:08:04 2021 +0200 First commit 07/01/2002 diff --git a/GNum.cpp b/GNum.cpp new file mode 100644 index 0000000..37c02b2 --- /dev/null +++ b/GNum.cpp @@ -0,0 +1,151 @@ +//--------------------------------------------------------------------------- + +#include +#pragma hdrstop + +#include +#include "GNum.h" +//--------------------------------------------------------------------------- +#pragma package(smart_init) +#pragma resource "*.dfm" +TForm1 *Form1; +//--------------------------------------------------------------------------- +__fastcall TForm1::TForm1(TComponent* Owner) + : TForm(Owner) +{ + ComboBox1->ItemIndex = 0; + ComboBox2->ItemIndex = 1; + ComboBox3->ItemIndex = 2; + ComboBox4->ItemIndex = 3; + ComboBox5->ItemIndex = 4; + ComboBox6->ItemIndex = 5; + mismaDecena->ItemIndex = 1; +} +//--------------------------------------------------------------------------- + + +void __fastcall TForm1::Button1Click(TObject *Sender) +{ + // Comprueba que no se repiten +/* + if ( (ComboBox1->ItemIndex != ComboBox2->ItemIndex && ComboBox1->ItemIndex != ComboBox3->ItemIndex && ComboBox1->ItemIndex != ComboBox4->ItemIndex && ComboBox1->ItemIndex != ComboBox5->ItemIndex && ComboBox1->ItemIndex != ComboBox6->ItemIndex ) && + (ComboBox2->ItemIndex != ComboBox3->ItemIndex && ComboBox2->ItemIndex != ComboBox4->ItemIndex && ComboBox2->ItemIndex != ComboBox5->ItemIndex && ComboBox2->ItemIndex != ComboBox6->ItemIndex ) && + (ComboBox3->ItemIndex != ComboBox4->ItemIndex && ComboBox3->ItemIndex != ComboBox5->ItemIndex && ComboBox3->ItemIndex != ComboBox6->ItemIndex ) && + (ComboBox4->ItemIndex != ComboBox5->ItemIndex && ComboBox4->ItemIndex != ComboBox6->ItemIndex ) && + (ComboBox5->ItemIndex != ComboBox6->ItemIndex ) + ) + */ + if ( (ComboBox1->ItemIndex < ComboBox2->ItemIndex && ComboBox2->ItemIndex < ComboBox3->ItemIndex && ComboBox1->ItemIndex < ComboBox4->ItemIndex && ComboBox1->ItemIndex < ComboBox5->ItemIndex && ComboBox1->ItemIndex < ComboBox6->ItemIndex ) ) + + { + // Comenzamos a generar + ShowMessage( "Ahora empezare a generar números, aunque parezca que estoy COLGADO, no es asi, sigo trabajando en tu petición" ); + + FILE *stream; + char buf1[20], buf2[20], buf3[20], buf4[20]; + char buffer[80]; + if ((stream = fopen("gnum.txt", "w+"))== NULL) + { + ShowMessage( "No puedo abrir el fichero. PUEDE que ya este en USO" ); + } else { + int V1 = ComboBox1->ItemIndex + 1; + int V2 = ComboBox2->ItemIndex + 1; + int V3 = ComboBox3->ItemIndex + 1; + int V4 = ComboBox4->ItemIndex + 1; + int V5 = ComboBox5->ItemIndex + 1; + int V6 = ComboBox6->ItemIndex + 1; + int ColumnaActual = 0; + long int Cuantos = 0, CuantosGenero = 0; + while(1) { + Cuantos++; + // Incrementamos (si nos lo permiten) la 1ª cifra + V6 ++; if ( V6 > 49 ) + { + if ( !CheckBox5->Checked ) break; + V5++; V6 = V5+1; + if ( V5 > 48 ) + { + if ( !CheckBox4->Checked ) break; + V4++; V5 = V4+1; V6 = V5+1; + if ( V4 > 47 ) + { + if ( !CheckBox3->Checked ) break; + V3++; V4 = V3+1; V5 = V4+1; V6 = V5+1; + if ( V3 > 46 ) + { + if ( !CheckBox2->Checked ) break; + V2++; V3 = V2+1; V4=V3+1; V5 = V4+1; V6 = V5+1; + if ( V2 > 45 ) + { + if ( !CheckBox1->Checked ) break; + V1++; V2=V1+1; V3=V2+1; V4=V3+1; V5 = V4+1; V6 = V5+1; + if ( V1 > 44 ) + { + break; + } + } + } + } + } + } + + if ( cumpleRestoCondiciones(V1, V2, V3, V4, V5, V6) ) + { + CuantosGenero++; + switch ( ColumnaActual ) + { + case 3: + sprintf( buf4, "%02d-%02d-%02d-%02d-%02d-%02d", V1, V2, V3, V4, V5, V6); + sprintf( buffer, "%s %s %s %s\r", buf1, buf2, buf3, buf4 ); + /* write some data to the file */ + fwrite(buffer, 79, 1, stream); + ColumnaActual = 0; + break; + case 2: + sprintf( buf3, "%02d-%02d-%02d-%02d-%02d-%02d", V1, V2, V3, V4, V5, V6); + ColumnaActual++; + break; + case 1: + sprintf( buf2, "%02d-%02d-%02d-%02d-%02d-%02d", V1, V2, V3, V4, V5, V6); + ColumnaActual++; + break; + case 0: + sprintf( buf1, "%02d-%02d-%02d-%02d-%02d-%02d", V1, V2, V3, V4, V5, V6); + ColumnaActual++; + break; + } + } + + }; + fclose(stream); + sprintf( buffer, "Ya he acabado. He generado %ld combinaciones y me he quedado con %ld.", Cuantos, CuantosGenero ); + ShowMessage( buffer ); + } + } else { + ShowMessage( "El número de comienzo no puede repetirse, y debe estar ordenado de MENOR a MAYOR" ); + } +} +//--------------------------------------------------------------------------- +bool __fastcall TForm1::cumpleRestoCondiciones(int V1, int V2, int V3, int V4, int V5, int V6) +{ + bool dev=true; + int numDistintaDecena = mismaDecena->ItemIndex + 3; + + // Verificamos que no haya mas de X números de la misma decena + int nDecenas[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + nDecenas[V1/10]++; + nDecenas[V2/10]++; + nDecenas[V3/10]++; + nDecenas[V4/10]++; + nDecenas[V5/10]++; + nDecenas[V6/10]++; + + + for ( int i=0;i<10;i++ ) + { + if ( nDecenas[i]>=numDistintaDecena ) { dev = false; break; } + } + + return dev; +} +//--------------------------------------------------------------------------- diff --git a/GNum.dfm b/GNum.dfm new file mode 100644 index 0000000..1c1f8cb --- /dev/null +++ b/GNum.dfm @@ -0,0 +1,482 @@ +object Form1: TForm1 + Left = 191 + Top = 116 + Width = 391 + Height = 392 + Caption = 'Generador de números' + Color = clBtnFace + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -24 + Font.Name = 'MS Sans Serif' + Font.Style = [] + OldCreateOrder = False + PixelsPerInch = 96 + TextHeight = 29 + object Label1: TLabel + Left = 8 + Top = 24 + Width = 258 + Height = 29 + Caption = 'Empezar por el número:' + end + object Label2: TLabel + Left = 32 + Top = 144 + Width = 319 + Height = 24 + Caption = '[el orden debe ser de menor a mayor]' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -19 + Font.Name = 'MS Sans Serif' + Font.Style = [] + ParentFont = False + end + object Label3: TLabel + Left = 32 + Top = 168 + Width = 311 + Height = 24 + Caption = 'y las casillas marcadas de V5->a->V1' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -19 + Font.Name = 'MS Sans Serif' + Font.Style = [] + ParentFont = False + end + object Label4: TLabel + Left = 8 + Top = 216 + Width = 322 + Height = 24 + Caption = 'No mas de de la misma decena.' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -19 + Font.Name = 'MS Sans Serif' + Font.Style = [] + ParentFont = False + end + object ComboBox1: TComboBox + Left = 8 + Top = 64 + Width = 49 + Height = 37 + ItemHeight = 29 + TabOrder = 0 + Text = '1' + Items.Strings = ( + '1' + '2' + '3' + '4' + '5' + '6' + '7' + '8' + '9' + '10' + '11' + '12' + '13' + '14' + '15' + '16' + '17' + '18' + '19' + '20' + '21' + '22' + '23' + '24' + '25' + '26' + '27' + '28' + '29' + '30' + '31' + '32' + '33' + '34' + '35' + '36' + '37' + '38' + '39' + '40' + '41' + '42' + '43' + '44' + '45' + '46' + '47' + '48' + '49') + end + object ComboBox2: TComboBox + Left = 72 + Top = 64 + Width = 49 + Height = 37 + ItemHeight = 29 + TabOrder = 1 + Text = '2' + Items.Strings = ( + '1' + '2' + '3' + '4' + '5' + '6' + '7' + '8' + '9' + '10' + '11' + '12' + '13' + '14' + '15' + '16' + '17' + '18' + '19' + '20' + '21' + '22' + '23' + '24' + '25' + '26' + '27' + '28' + '29' + '30' + '31' + '32' + '33' + '34' + '35' + '36' + '37' + '38' + '39' + '40' + '41' + '42' + '43' + '44' + '45' + '46' + '47' + '48' + '49') + end + object ComboBox3: TComboBox + Left = 136 + Top = 64 + Width = 49 + Height = 37 + ItemHeight = 29 + TabOrder = 2 + Text = '3' + Items.Strings = ( + '1' + '2' + '3' + '4' + '5' + '6' + '7' + '8' + '9' + '10' + '11' + '12' + '13' + '14' + '15' + '16' + '17' + '18' + '19' + '20' + '21' + '22' + '23' + '24' + '25' + '26' + '27' + '28' + '29' + '30' + '31' + '32' + '33' + '34' + '35' + '36' + '37' + '38' + '39' + '40' + '41' + '42' + '43' + '44' + '45' + '46' + '47' + '48' + '49') + end + object ComboBox4: TComboBox + Left = 200 + Top = 64 + Width = 49 + Height = 37 + ItemHeight = 29 + TabOrder = 3 + Text = '4' + Items.Strings = ( + '1' + '2' + '3' + '4' + '5' + '6' + '7' + '8' + '9' + '10' + '11' + '12' + '13' + '14' + '15' + '16' + '17' + '18' + '19' + '20' + '21' + '22' + '23' + '24' + '25' + '26' + '27' + '28' + '29' + '30' + '31' + '32' + '33' + '34' + '35' + '36' + '37' + '38' + '39' + '40' + '41' + '42' + '43' + '44' + '45' + '46' + '47' + '48' + '49') + end + object ComboBox5: TComboBox + Left = 264 + Top = 64 + Width = 49 + Height = 37 + ItemHeight = 29 + TabOrder = 4 + Text = '5' + Items.Strings = ( + '1' + '2' + '3' + '4' + '5' + '6' + '7' + '8' + '9' + '10' + '11' + '12' + '13' + '14' + '15' + '16' + '17' + '18' + '19' + '20' + '21' + '22' + '23' + '24' + '25' + '26' + '27' + '28' + '29' + '30' + '31' + '32' + '33' + '34' + '35' + '36' + '37' + '38' + '39' + '40' + '41' + '42' + '43' + '44' + '45' + '46' + '47' + '48' + '49') + end + object ComboBox6: TComboBox + Left = 328 + Top = 64 + Width = 49 + Height = 37 + ItemHeight = 29 + TabOrder = 5 + Text = '6' + Items.Strings = ( + '1' + '2' + '3' + '4' + '5' + '6' + '7' + '8' + '9' + '10' + '11' + '12' + '13' + '14' + '15' + '16' + '17' + '18' + '19' + '20' + '21' + '22' + '23' + '24' + '25' + '26' + '27' + '28' + '29' + '30' + '31' + '32' + '33' + '34' + '35' + '36' + '37' + '38' + '39' + '40' + '41' + '42' + '43' + '44' + '45' + '46' + '47' + '48' + '49') + end + object CheckBox1: TCheckBox + Left = 8 + Top = 112 + Width = 49 + Height = 17 + Caption = 'v1' + TabOrder = 6 + end + object CheckBox2: TCheckBox + Left = 72 + Top = 112 + Width = 49 + Height = 17 + Caption = 'v2' + TabOrder = 7 + end + object CheckBox3: TCheckBox + Left = 136 + Top = 112 + Width = 49 + Height = 17 + Caption = 'v3' + TabOrder = 8 + end + object CheckBox4: TCheckBox + Left = 200 + Top = 112 + Width = 49 + Height = 17 + Caption = 'v4' + TabOrder = 9 + end + object CheckBox5: TCheckBox + Left = 264 + Top = 112 + Width = 49 + Height = 17 + Caption = 'v5' + TabOrder = 10 + end + object Button1: TButton + Left = 24 + Top = 312 + Width = 345 + Height = 49 + Caption = '&Generar >> gnum.txt' + TabOrder = 11 + OnClick = Button1Click + end + object mismaDecena: TComboBox + Left = 104 + Top = 208 + Width = 49 + Height = 37 + ItemHeight = 29 + TabOrder = 12 + Text = '2' + Items.Strings = ( + '3' + '4' + '5' + '6' + '7' + '8' + '9') + end +end diff --git a/GNum.h b/GNum.h new file mode 100644 index 0000000..d14f2c7 --- /dev/null +++ b/GNum.h @@ -0,0 +1,41 @@ +//--------------------------------------------------------------------------- + +#ifndef GNumH +#define GNumH +//--------------------------------------------------------------------------- +#include +#include +#include +#include +//--------------------------------------------------------------------------- +class TForm1 : public TForm +{ +__published: // IDE-managed Components + TComboBox *ComboBox1; + TLabel *Label1; + TComboBox *ComboBox2; + TComboBox *ComboBox3; + TComboBox *ComboBox4; + TComboBox *ComboBox5; + TComboBox *ComboBox6; + TCheckBox *CheckBox1; + TCheckBox *CheckBox2; + TCheckBox *CheckBox3; + TCheckBox *CheckBox4; + TCheckBox *CheckBox5; + TButton *Button1; + TLabel *Label2; + TLabel *Label3; + TComboBox *mismaDecena; + TLabel *Label4; + void __fastcall Button1Click(TObject *Sender); +private: // User declarations +public: // User declarations + __fastcall TForm1(TComponent* Owner); + bool __fastcall cumpleRestoCondiciones(int V1, int V2, int V3, int V4, int V5, int V6); + +}; +//--------------------------------------------------------------------------- +extern PACKAGE TForm1 *Form1; +//--------------------------------------------------------------------------- +#endif diff --git a/GeNum.bpr b/GeNum.bpr new file mode 100644 index 0000000..9c46caa --- /dev/null +++ b/GeNum.bpr @@ -0,0 +1,104 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +[Version Info] +IncludeVerInfo=0 +AutoIncBuild=0 +MajorVer=1 +MinorVer=0 +Release=0 +Build=0 +Debug=0 +PreRelease=0 +Special=0 +Private=0 +DLL=0 +Locale=3082 +CodePage=1252 + +[Version Info Keys] +CompanyName= +FileDescription= +FileVersion=1.0.0.0 +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion=1.0.0.0 +Comments= + +[Debugging] +DebugSourceDirs=$(BCB)\source\vcl + +[Parameters] +RunParams= +HostApplication= +RemoteHost= +RemotePath= +RemoteDebug=0 + +[Compiler] +ShowInfoMsgs=0 +LinkDebugVcl=0 +LinkCGLIB=0 + +[CORBA] +AddServerUnit=1 +AddClientUnit=1 +PrecompiledHeaders=1 + +[Language] +ActiveLang= +ProjectLang= +RootDir= + + \ No newline at end of file diff --git a/GeNum.cpp b/GeNum.cpp new file mode 100644 index 0000000..8563e7e --- /dev/null +++ b/GeNum.cpp @@ -0,0 +1,22 @@ +//--------------------------------------------------------------------------- + +#include +#pragma hdrstop +USERES("GeNum.res"); +USEFORM("GNum.cpp", Form1); +//--------------------------------------------------------------------------- +WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) +{ + try + { + Application->Initialize(); + Application->CreateForm(__classid(TForm1), &Form1); + Application->Run(); + } + catch (Exception &exception) + { + Application->ShowException(&exception); + } + return 0; +} +//--------------------------------------------------------------------------- diff --git a/GeNum.exe b/GeNum.exe new file mode 100644 index 0000000..b70cc4e Binary files /dev/null and b/GeNum.exe differ diff --git a/GeNum.rar b/GeNum.rar new file mode 100644 index 0000000..8d8e3a4 Binary files /dev/null and b/GeNum.rar differ diff --git a/GeNum.res b/GeNum.res new file mode 100644 index 0000000..1392cb0 Binary files /dev/null and b/GeNum.res differ diff --git a/README.md b/README.md new file mode 100644 index 0000000..56f7a8b --- /dev/null +++ b/README.md @@ -0,0 +1,9 @@ +#GeneradorDeNumeros + + +*07/01/2002* + +ToDo: wwtcf? + + +![screenshot](/GeneradorDeNumeros.png "Screenshot")