X-Git-Url: https://git.llucax.com/z.facultad/75.40/1er-cuat/orden.git/blobdiff_plain/01ce990c404c3050fa816bf88c0dae98360536cb..41295f9e0972a2c89165fb6fbe737bbe56672be3:/test/tsrndnms.pas diff --git a/test/tsrndnms.pas b/test/tsrndnms.pas index 8bc3d9b..dae1c47 100644 --- a/test/tsrndnms.pas +++ b/test/tsrndnms.pas @@ -1,229 +1,229 @@ -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; +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;