First commit 07/01/2002

This commit is contained in:
José David Guillén 2021-09-12 22:08:04 +02:00
commit a0ad7d8960
9 changed files with 809 additions and 0 deletions

151
GNum.cpp Normal file
View File

@ -0,0 +1,151 @@
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include <stdio.h>
#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;
}
//---------------------------------------------------------------------------

482
GNum.dfm Normal file
View File

@ -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

41
GNum.h Normal file
View File

@ -0,0 +1,41 @@
//---------------------------------------------------------------------------
#ifndef GNumH
#define GNumH
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
//---------------------------------------------------------------------------
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

104
GeNum.bpr Normal file
View File

@ -0,0 +1,104 @@
<?xml version='1.0' encoding='utf-8' ?>
<!-- C++Builder XML Project -->
<PROJECT>
<MACROS>
<VERSION value="BCB.05.03"/>
<PROJECT value="GeNum.exe"/>
<OBJFILES value="GeNum.obj GNum.obj"/>
<RESFILES value="GeNum.res"/>
<IDLFILES value=""/>
<IDLGENFILES value=""/>
<DEFFILE value=""/>
<RESDEPEN value="$(RESFILES) GNum.dfm"/>
<LIBFILES value=""/>
<LIBRARIES value="VCL50.lib"/>
<SPARELIBS value="VCL50.lib"/>
<PACKAGES value="VCL50.bpi VCLX50.bpi VCLDB50.bpi VCLBDE50.bpi VCLDBX50.bpi QRPT50.bpi
TEEUI50.bpi TEEDB50.bpi TEE50.bpi DSS50.bpi TEEQR50.bpi VCLIE50.bpi
INETDB50.bpi INET50.bpi VCLMID50.bpi NMFAST50.bpi dclocx50.bpi asgc5.bpi
CabForCB.bpi CoolPack.bpi JDsoft.bpi PhantomPack.bpi RAS_Tools.bpi
ZCommonCB5.bpi ZDbwareCB5.bpi ZMySqlCB5.bpi bcbsmp50.bpi VCLADO50.bpi
ibsmp50.bpi VCLIB50.bpi WEBMID50.bpi bcbie50.bpi bcb2kaxserver50.bpi
ZDb2SqlCB5.bpi ZIbSqlCB5.bpi ZMsSqlCB5.bpi ZOraSqlCB5.bpi ZPgSqlCB5.bpi"/>
<PATHCPP value=".;"/>
<PATHPAS value=".;"/>
<PATHRC value=".;"/>
<PATHASM value=".;"/>
<DEBUGLIBPATH value="$(BCB)\lib\debug"/>
<RELEASELIBPATH value="$(BCB)\lib\release"/>
<LINKER value="tlink32"/>
<USERDEFINES value="_DEBUG"/>
<SYSDEFINES value="NO_STRICT"/>
<MAINSOURCE value="GeNum.cpp"/>
<INCLUDEPATH value="$(BCB)\include;$(BCB)\include\vcl"/>
<LIBPATH value="$(BCB)\Projects\Lib;..\VCLs\lib;$(BCB)\lib\obj;$(BCB)\lib"/>
<WARNINGS value="-w-par"/>
</MACROS>
<OPTIONS>
<IDLCFLAGS value="-I$(BCB)\include -I$(BCB)\include\vcl -src_suffix cpp -D_DEBUG -boa"/>
<CFLAG1 value="-Od -H=$(BCB)\lib\vcl50.csm -Hc -Vx -Ve -X- -r- -a8 -b- -k -y -v -vi- -c
-tW -tWM"/>
<PFLAGS value="-$YD -$W -$O- -v -JPHNE -M"/>
<RFLAGS value=""/>
<AFLAGS value="/mx /w2 /zd"/>
<LFLAGS value="-D&quot;&quot; -aa -Tpe -x -Gn -v"/>
</OPTIONS>
<LINKER>
<ALLOBJ value="c0w32.obj sysinit.obj $(OBJFILES)"/>
<ALLRES value="$(RESFILES)"/>
<ALLLIB value="$(LIBFILES) $(LIBRARIES) import32.lib cp32mt.lib"/>
</LINKER>
<IDEOPTIONS>
[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=
</IDEOPTIONS>
</PROJECT>

22
GeNum.cpp Normal file
View File

@ -0,0 +1,22 @@
//---------------------------------------------------------------------------
#include <vcl.h>
#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;
}
//---------------------------------------------------------------------------

BIN
GeNum.exe Normal file

Binary file not shown.

BIN
GeNum.rar Normal file

Binary file not shown.

BIN
GeNum.res Normal file

Binary file not shown.

9
README.md Normal file
View File

@ -0,0 +1,9 @@
#GeneradorDeNumeros
*07/01/2002*
ToDo: wwtcf?
![screenshot](/GeneradorDeNumeros.png "Screenshot")