-program RNDNames;\r
-\r
-const\r
- MAX_APE = 30;\r
-\r
-type\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
- APELLIDO = string[MAX_APE];\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 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( 20 ) = 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( 15 ) = 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( 20 ) = 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( 15 ) = 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( 35 ) = 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( 15 ) = 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( 15 ) = 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( 10 ) = 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( 20 ) = 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;\r
- end;\r
- end; { case indic of }\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 proxl 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
- if random( 25 ) = 0 then proxl := TL_VOCAL\r
- else 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
- function GetRNDApellido( max, min: integer ): APELLIDO;\r
-\r
- var\r
- tam, i: integer;\r
- aux: char;\r
- apellido: 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
- apellido := '';\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
- apellido := apellido + aux;\r
- end;\r
- GetRNDApellido := apellido;\r
- end;\r
-\r
-var\r
- n, i: integer;\r
-\r
-begin\r
- randomize; (* inicializa la semilla del random *)\r
-\r
- write( 'Ingrese la cantidad de apellidos a generar: ' );\r
- readln( n );\r
- for i := 1 to n do\r
- writeln( GetRNDApellido( 30, 4 ) );\r
- writeln;\r
- writeln( ' FIN!!!' );\r
-end;\r
+program RNDNames;
+
+const
+ MAX_APE = 30;
+
+type
+ 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 );
+ APELLIDO = string[MAX_APE];
+
+(*********************************************************)
+
+ 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 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( 20 ) = 0 then begin
+ indic := I_ESB;
+ proxl := TL_CONSO;
+ end;
+ end;
+ 4..7: begin
+ conso := 'C';
+ if random( 15 ) = 0 then begin
+ indic := I_ESC;
+ proxl := TL_CONSO;
+ end;
+ end;
+ 8..11: conso := 'D';
+ 12..14: begin
+ conso := 'F';
+ if random( 20 ) = 0 then begin
+ indic := I_ESF;
+ proxl := TL_CONSO;
+ end;
+ end;
+ 15..17: begin
+ conso := 'G';
+ if random( 15 ) = 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( 35 ) = 0 then
+ begin
+ indic := I_ESL;
+ proxl := TL_CONSO;
+ end;
+ end;
+ 28..30: begin
+ conso := 'M';
+ if random( 15 ) = 0 then
+ begin
+ indic := I_ESM;
+ proxl := TL_CONSO;
+ end;
+ end;
+ 31..33: begin
+ conso := 'N';
+ if random( 15 ) = 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( 10 ) = 0 then
+ begin
+ indic := I_ESR;
+ proxl := TL_CONSO;
+ end;
+ end;
+ 42..44: conso := 'S';
+ 45..47: begin
+ conso := 'T';
+ if random( 20 ) = 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;
+ end;
+ end; { case indic of }
+ end;
+
+(*********************************************************)
+
+ procedure GetRNDVocal( var indic: INDICADOR; var proxl: TIPO_LETRA; var vocal: char );
+
+ var
+ valor: integer;
+
+ begin
+ case proxl of
+ I_ESQ:
+ begin
+ vocal := 'U';
+ indic := I_ESQU;
+ proxl := TL_VOCAL;
+ end;
+ I_ESQU:
+ begin
+ vocal := GetVocal( TV_EI );
+ indic := I_NADA;
+ if random( 25 ) = 0 then proxl := TL_VOCAL
+ else 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;
+
+(*********************************************************)
+
+ function GetRNDApellido( max, min: integer ): APELLIDO;
+
+ var
+ tam, i: integer;
+ aux: char;
+ apellido: APELLIDO;
+ indic: INDICADOR;
+ proxl: TIPO_LETRA;
+
+ begin
+ if max > MAX_APE then max := MAX_APE;
+ tam := random( max + 1 ) + min;
+ indic := I_NADA;
+ apellido := '';
+ 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 );
+ apellido := apellido + aux;
+ end;
+ GetRNDApellido := apellido;
+ end;
+
+var
+ n, i: integer;
+
+begin
+ randomize; (* inicializa la semilla del random *)
+
+ write( 'Ingrese la cantidad de apellidos a generar: ' );
+ readln( n );
+ for i := 1 to n do
+ writeln( GetRNDApellido( 30, 4 ) );
+ writeln;
+ writeln( ' FIN!!!' );
+end;