-program Generador_De_Nombres_Ordenados_Alfabeticamente;\r
-\r
-uses\r
- CRT;\r
-\r
-const\r
- MAX_APE = 15;\r
-\r
-type\r
- APELLIDO = string[MAX_APE];\r
- DOCUMENTO = 10000000..40000000;\r
- PERSONA = record\r
- ap: APELLIDO;\r
- dni: DOCUMENTO;\r
- end;\r
- TABLA = array[1..1000] of PERSONA;\r
- TIPO_LETRA = ( TL_VOCAL, TL_CONSO );\r
- TIPO_VOCAL = ( TV_AEIOU, TV_EI );\r
- INDICADOR = ( I_NADA, I_ESB, I_ESC, I_ESF, I_ESG, I_ESL, I_ESM, I_ESN, I_ESQ, I_ESQU, I_ESR, I_EST );\r
-\r
-(*********************************************************)\r
-\r
- function GetVocal( tipo: TIPO_VOCAL ): char;\r
-\r
- var\r
- valor: integer;\r
-\r
- begin\r
- if tipo = TV_AEIOU then valor := random( 16 )\r
- else valor := random( 6 ) + 5;\r
- case valor of\r
- 0..4: GetVocal := 'A';\r
- 5..7: GetVocal := 'E';\r
- 8..10: GetVocal := 'I';\r
- 11..13: GetVocal := 'O';\r
- 14..15: GetVocal := 'U';\r
- end;\r
- end;\r
-\r
-(*********************************************************)\r
-\r
- procedure GetRNDVocal( var indic: INDICADOR; var proxl: TIPO_LETRA; var vocal: char );\r
-\r
- var\r
- valor: integer;\r
-\r
- begin\r
- case indic of\r
- I_ESQ:\r
- begin\r
- vocal := 'U';\r
- indic := I_ESQU;\r
- proxl := TL_VOCAL;\r
- end;\r
- I_ESQU:\r
- begin\r
- vocal := GetVocal( TV_EI );\r
- indic := I_NADA;\r
- proxl := TL_CONSO;\r
- end;\r
- else\r
- begin\r
- vocal := GetVocal( TV_AEIOU );\r
- indic := I_NADA;\r
- if random( 40 ) = 0 then proxl := TL_VOCAL\r
- else proxl := TL_CONSO;\r
- end;\r
- end;\r
- end;\r
-\r
-(*********************************************************)\r
-\r
- procedure GetRNDConsonante( var indic: INDICADOR; var proxl: TIPO_LETRA; var conso: char );\r
-\r
- var\r
- valor: integer;\r
-\r
- begin\r
- proxl := TL_VOCAL;\r
- indic := I_NADA;\r
-\r
- case indic of\r
- I_ESF, I_ESR, I_ESG, I_EST: conso := 'R';\r
- I_ESB: case random( 2 ) of\r
- 0: conso := 'R';\r
- 1: conso := 'L';\r
- end;\r
- I_ESC: case random( 4 ) of\r
- 0: conso := 'C';\r
- 1: conso := 'H';\r
- 2: conso := 'R';\r
- 3: conso := 'L';\r
- end;\r
- I_ESL: case random( 6 ) of\r
- 0: conso := 'T';\r
- 1..5: conso := 'L';\r
- end;\r
- I_ESM: case random( 3 ) of\r
- 0: conso := 'P';\r
- 1: conso := 'B';\r
- 2: conso := 'L';\r
- end;\r
- I_ESN: case random( 3 ) of\r
- 0: conso := 'R';\r
- 1: conso := 'V';\r
- 2: conso := 'C';\r
- end;\r
- else case random( 55 ) of\r
- 0..3: begin\r
- conso := 'B';\r
- if random( 10 ) = 0 then begin\r
- indic := I_ESB;\r
- proxl := TL_CONSO;\r
- end;\r
- end;\r
- 4..7: begin\r
- conso := 'C';\r
- if random( 5 ) = 0 then begin\r
- indic := I_ESC;\r
- proxl := TL_CONSO;\r
- end;\r
- end;\r
- 8..11: conso := 'D';\r
- 12..14: begin\r
- conso := 'F';\r
- if random( 10 ) = 0 then begin\r
- indic := I_ESF;\r
- proxl := TL_CONSO;\r
- end;\r
- end;\r
- 15..17: begin\r
- conso := 'G';\r
- if random( 5 ) = 0 then\r
- begin\r
- indic := I_ESG;\r
- if random( 4 ) = 0 then proxl := TL_CONSO;\r
- end;\r
- end;\r
- 18..19: conso := 'H';\r
- 20..22: conso := 'J';\r
- 23..24: conso := 'K';\r
- 25..27: begin\r
- conso := 'L';\r
- if random( 15 ) = 0 then\r
- begin\r
- indic := I_ESL;\r
- proxl := TL_CONSO;\r
- end;\r
- end;\r
- 28..30: begin\r
- conso := 'M';\r
- if random( 5 ) = 0 then\r
- begin\r
- indic := I_ESM;\r
- proxl := TL_CONSO;\r
- end;\r
- end;\r
- 31..33: begin\r
- conso := 'N';\r
- if random( 5 ) = 0 then\r
- begin\r
- indic := I_ESN;\r
- proxl := TL_CONSO;\r
- end;\r
- end;\r
- 34..36: conso := 'P';\r
- 37..38: begin\r
- conso := 'Q';\r
- indic := I_ESQ;\r
- end;\r
- 39..41: begin\r
- conso := 'R';\r
- if random( 3 ) = 0 then\r
- begin\r
- indic := I_ESR;\r
- proxl := TL_CONSO;\r
- end;\r
- end;\r
- 42..44: conso := 'S';\r
- 45..47: begin\r
- conso := 'T';\r
- if random( 10 ) = 0 then\r
- begin\r
- indic := I_EST;\r
- proxl := TL_CONSO;\r
- end;\r
- end;\r
- 48..50: conso := 'V';\r
- 51: conso := 'W';\r
- 52: conso := 'X';\r
- 53: conso := 'Y';\r
- 54: conso := 'Z';\r
- end; { case random( 55 ) of }\r
-\r
- end; { case indic of }\r
- end; { procedimiento }\r
-\r
-(*********************************************************)\r
-\r
- function GetRNDApellido( max, min: integer ): APELLIDO;\r
-\r
- var\r
- tam, i: integer;\r
- aux: char;\r
- apel: APELLIDO;\r
- indic: INDICADOR;\r
- proxl: TIPO_LETRA;\r
-\r
- begin\r
- if max > MAX_APE then max := MAX_APE;\r
- tam := random( max + 1 ) + min;\r
- indic := I_NADA;\r
- apel := '';\r
- if random( 5 ) = 0 then proxl := TL_VOCAL\r
- else proxl := TL_CONSO;\r
- for i := 1 to tam do\r
- begin\r
- if proxl = TL_CONSO then GetRNDConsonante( indic, proxl, aux )\r
- else GetRNDVocal( indic, proxl, aux );\r
- apel := apel + aux;\r
- end;\r
- GetRNDApellido := apel;\r
- end;\r
-\r
-(*********************************************************)\r
-\r
- function GetRNDLetra( min, max: char ): char;\r
-\r
- begin\r
- GetRNDLetra := chr( random( ord( max ) - ord( min ) + 1 ) + ord( min ) );\r
- end;\r
-\r
-\r
-(*********************************************************)\r
- procedure GetInvOrdApellidos( var ar: text; cant: integer );\r
-\r
- var\r
- mil: boolean;\r
- letra, letra1: char;\r
- i, j, veces: integer;\r
- dni: DOCUMENTO;\r
- ap, ape, apel: APELLIDO;\r
-\r
- begin\r
- mil := false;\r
- if cant = 1000 then mil := true;\r
- dni := 34000000 + (random( 15000 ) * 100);\r
- ap := '';\r
- ape := '';\r
- apel := '';\r
- for letra := 'Z' downto 'A' do\r
- begin\r
- ap := letra;\r
- for letra1 := 'Z' downto 'A' do\r
- begin\r
- if mil then\r
- case letra of\r
- 'A', 'B', 'C', 'E', 'L', 'M', 'N', 'O', 'P', 'R', 'S', 'T':\r
- case letra1 of\r
- 'A', 'B', 'C', 'E', 'L', 'M', 'N', 'O', 'P', 'R', 'S', 'T', 'Z': veces := 2;\r
- else veces := 1;\r
- end;\r
- else case letra1 of\r
- 'A', 'B', 'C', 'E', 'L', 'M', 'N', 'O', 'P', 'R', 'S', 'T': veces := 2;\r
- else veces := 1;\r
- end;\r
- end\r
- else\r
- case letra of\r
- 'A', 'B', 'C', 'D', 'E', 'F', 'I', 'L', 'M', 'N', 'O', 'P', 'R', 'S', 'T', 'V':\r
- case letra1 of\r
- 'D', 'F', 'G', 'H', 'I', 'J', 'K', 'U', 'V': veces := 2;\r
- else veces := 1;\r
- end;\r
- else case letra1 of\r
- 'D', 'F', 'G', 'H', 'I', 'J', 'K', 'U': veces := 2;\r
- else veces := 1;\r
- end;\r
- end;\r
- ape := ap + letra1;\r
- for j := 1 to veces do\r
- begin\r
- if j <> 1 then apel := ape + GetRNDLetra( 'A', 'M' ) + GetRNDApellido( 6, 1 )\r
- else apel := ape + GetRNDLetra( 'N', 'Z' ) + GetRNDApellido( 6, 1 );\r
- dni := dni - random( 50000 ) - 1;\r
- writeln( ar, apel );\r
- writeln( ar, dni );\r
- writeln( ar );\r
- apel := '';\r
- end;\r
-\r
- ape := '';\r
-\r
- end; { for letra1 := 'A' to 'Z' do }\r
-\r
- ap := '';\r
-\r
- end; { for letra := 'A' to 'Z' do }\r
-\r
- end; { procedure }\r
-\r
-(*********************************************************)\r
-\r
-var\r
- datos: TABLA;\r
- arch: text;\r
- dni: DOCUMENTO;\r
- i, n: integer;\r
-\r
-begin\r
- randomize;\r
-\r
- n := 1000;\r
- assign( arch, 'DATOS.TXT' );\r
- rewrite( arch );\r
- readln( n );\r
- GetInvOrdApellidos( arch, n );\r
- close( arch );\r
+program Generador_De_Nombres_Ordenados_Alfabeticamente;
+
+uses
+ CRT;
+
+const
+ MAX_APE = 15;
+
+type
+ APELLIDO = string[MAX_APE];
+ DOCUMENTO = 10000000..40000000;
+ PERSONA = record
+ ap: APELLIDO;
+ dni: DOCUMENTO;
+ end;
+ TABLA = array[1..1000] of PERSONA;
+ TIPO_LETRA = ( TL_VOCAL, TL_CONSO );
+ TIPO_VOCAL = ( TV_AEIOU, TV_EI );
+ INDICADOR = ( I_NADA, I_ESB, I_ESC, I_ESF, I_ESG, I_ESL, I_ESM, I_ESN, I_ESQ, I_ESQU, I_ESR, I_EST );
+
+(*********************************************************)
+
+ function GetVocal( tipo: TIPO_VOCAL ): char;
+
+ var
+ valor: integer;
+
+ begin
+ if tipo = TV_AEIOU then valor := random( 16 )
+ else valor := random( 6 ) + 5;
+ case valor of
+ 0..4: GetVocal := 'A';
+ 5..7: GetVocal := 'E';
+ 8..10: GetVocal := 'I';
+ 11..13: GetVocal := 'O';
+ 14..15: GetVocal := 'U';
+ end;
+ end;
+
+(*********************************************************)
+
+ procedure GetRNDVocal( var indic: INDICADOR; var proxl: TIPO_LETRA; var vocal: char );
+
+ var
+ valor: integer;
+
+ begin
+ case indic of
+ I_ESQ:
+ begin
+ vocal := 'U';
+ indic := I_ESQU;
+ proxl := TL_VOCAL;
+ end;
+ I_ESQU:
+ begin
+ vocal := GetVocal( TV_EI );
+ indic := I_NADA;
+ proxl := TL_CONSO;
+ end;
+ else
+ begin
+ vocal := GetVocal( TV_AEIOU );
+ indic := I_NADA;
+ if random( 40 ) = 0 then proxl := TL_VOCAL
+ else proxl := TL_CONSO;
+ end;
+ end;
+ end;
+
+(*********************************************************)
+
+ procedure GetRNDConsonante( var indic: INDICADOR; var proxl: TIPO_LETRA; var conso: char );
+
+ var
+ valor: integer;
+
+ begin
+ proxl := TL_VOCAL;
+ indic := I_NADA;
+
+ case indic of
+ I_ESF, I_ESR, I_ESG, I_EST: conso := 'R';
+ I_ESB: case random( 2 ) of
+ 0: conso := 'R';
+ 1: conso := 'L';
+ end;
+ I_ESC: case random( 4 ) of
+ 0: conso := 'C';
+ 1: conso := 'H';
+ 2: conso := 'R';
+ 3: conso := 'L';
+ end;
+ I_ESL: case random( 6 ) of
+ 0: conso := 'T';
+ 1..5: conso := 'L';
+ end;
+ I_ESM: case random( 3 ) of
+ 0: conso := 'P';
+ 1: conso := 'B';
+ 2: conso := 'L';
+ end;
+ I_ESN: case random( 3 ) of
+ 0: conso := 'R';
+ 1: conso := 'V';
+ 2: conso := 'C';
+ end;
+ else case random( 55 ) of
+ 0..3: begin
+ conso := 'B';
+ if random( 10 ) = 0 then begin
+ indic := I_ESB;
+ proxl := TL_CONSO;
+ end;
+ end;
+ 4..7: begin
+ conso := 'C';
+ if random( 5 ) = 0 then begin
+ indic := I_ESC;
+ proxl := TL_CONSO;
+ end;
+ end;
+ 8..11: conso := 'D';
+ 12..14: begin
+ conso := 'F';
+ if random( 10 ) = 0 then begin
+ indic := I_ESF;
+ proxl := TL_CONSO;
+ end;
+ end;
+ 15..17: begin
+ conso := 'G';
+ if random( 5 ) = 0 then
+ begin
+ indic := I_ESG;
+ if random( 4 ) = 0 then proxl := TL_CONSO;
+ end;
+ end;
+ 18..19: conso := 'H';
+ 20..22: conso := 'J';
+ 23..24: conso := 'K';
+ 25..27: begin
+ conso := 'L';
+ if random( 15 ) = 0 then
+ begin
+ indic := I_ESL;
+ proxl := TL_CONSO;
+ end;
+ end;
+ 28..30: begin
+ conso := 'M';
+ if random( 5 ) = 0 then
+ begin
+ indic := I_ESM;
+ proxl := TL_CONSO;
+ end;
+ end;
+ 31..33: begin
+ conso := 'N';
+ if random( 5 ) = 0 then
+ begin
+ indic := I_ESN;
+ proxl := TL_CONSO;
+ end;
+ end;
+ 34..36: conso := 'P';
+ 37..38: begin
+ conso := 'Q';
+ indic := I_ESQ;
+ end;
+ 39..41: begin
+ conso := 'R';
+ if random( 3 ) = 0 then
+ begin
+ indic := I_ESR;
+ proxl := TL_CONSO;
+ end;
+ end;
+ 42..44: conso := 'S';
+ 45..47: begin
+ conso := 'T';
+ if random( 10 ) = 0 then
+ begin
+ indic := I_EST;
+ proxl := TL_CONSO;
+ end;
+ end;
+ 48..50: conso := 'V';
+ 51: conso := 'W';
+ 52: conso := 'X';
+ 53: conso := 'Y';
+ 54: conso := 'Z';
+ end; { case random( 55 ) of }
+
+ end; { case indic of }
+ end; { procedimiento }
+
+(*********************************************************)
+
+ function GetRNDApellido( max, min: integer ): APELLIDO;
+
+ var
+ tam, i: integer;
+ aux: char;
+ apel: APELLIDO;
+ indic: INDICADOR;
+ proxl: TIPO_LETRA;
+
+ begin
+ if max > MAX_APE then max := MAX_APE;
+ tam := random( max + 1 ) + min;
+ indic := I_NADA;
+ apel := '';
+ if random( 5 ) = 0 then proxl := TL_VOCAL
+ else proxl := TL_CONSO;
+ for i := 1 to tam do
+ begin
+ if proxl = TL_CONSO then GetRNDConsonante( indic, proxl, aux )
+ else GetRNDVocal( indic, proxl, aux );
+ apel := apel + aux;
+ end;
+ GetRNDApellido := apel;
+ end;
+
+(*********************************************************)
+
+ function GetRNDLetra( min, max: char ): char;
+
+ begin
+ GetRNDLetra := chr( random( ord( max ) - ord( min ) + 1 ) + ord( min ) );
+ end;
+
+
+(*********************************************************)
+ procedure GetInvOrdApellidos( var ar: text; cant: integer );
+
+ var
+ mil: boolean;
+ letra, letra1: char;
+ i, j, veces: integer;
+ dni: DOCUMENTO;
+ ap, ape, apel: APELLIDO;
+
+ begin
+ mil := false;
+ if cant = 1000 then mil := true;
+ dni := 34000000 + (random( 15000 ) * 100);
+ ap := '';
+ ape := '';
+ apel := '';
+ for letra := 'Z' downto 'A' do
+ begin
+ ap := letra;
+ for letra1 := 'Z' downto 'A' do
+ begin
+ if mil then
+ case letra of
+ 'A', 'B', 'C', 'E', 'L', 'M', 'N', 'O', 'P', 'R', 'S', 'T':
+ case letra1 of
+ 'A', 'B', 'C', 'E', 'L', 'M', 'N', 'O', 'P', 'R', 'S', 'T', 'Z': veces := 2;
+ else veces := 1;
+ end;
+ else case letra1 of
+ 'A', 'B', 'C', 'E', 'L', 'M', 'N', 'O', 'P', 'R', 'S', 'T': veces := 2;
+ else veces := 1;
+ end;
+ end
+ else
+ case letra of
+ 'A', 'B', 'C', 'D', 'E', 'F', 'I', 'L', 'M', 'N', 'O', 'P', 'R', 'S', 'T', 'V':
+ case letra1 of
+ 'D', 'F', 'G', 'H', 'I', 'J', 'K', 'U', 'V': veces := 2;
+ else veces := 1;
+ end;
+ else case letra1 of
+ 'D', 'F', 'G', 'H', 'I', 'J', 'K', 'U': veces := 2;
+ else veces := 1;
+ end;
+ end;
+ ape := ap + letra1;
+ for j := 1 to veces do
+ begin
+ if j <> 1 then apel := ape + GetRNDLetra( 'A', 'M' ) + GetRNDApellido( 6, 1 )
+ else apel := ape + GetRNDLetra( 'N', 'Z' ) + GetRNDApellido( 6, 1 );
+ dni := dni - random( 50000 ) - 1;
+ writeln( ar, apel );
+ writeln( ar, dni );
+ writeln( ar );
+ apel := '';
+ end;
+
+ ape := '';
+
+ end; { for letra1 := 'A' to 'Z' do }
+
+ ap := '';
+
+ end; { for letra := 'A' to 'Z' do }
+
+ end; { procedure }
+
+(*********************************************************)
+
+var
+ datos: TABLA;
+ arch: text;
+ dni: DOCUMENTO;
+ i, n: integer;
+
+begin
+ randomize;
+
+ n := 1000;
+ assign( arch, 'DATOS.TXT' );
+ rewrite( arch );
+ readln( n );
+ GetInvOrdApellidos( arch, n );
+ close( arch );
end.
\ No newline at end of file