LENGUAJES DE PROGRAMACIÓN  
 
 
FreePascal

PASCAL CON FREE PASCAL

 
 

 

5.9. Respuestas a las preguntas y ejercicios.

 

anterior :: indice :: siguiente

 

1.

 

Si.

 

2.

 

No.

 

3.

 

Si.

 

4.

 

Indique si los siguientes programas se pueden compilar :

 

No se puede compilar : A,C.

Se puede compilar : B

 

5.

 

Cree los programas que se describen a continuación (arreglos):

 

   

 

 

A)

 
{$codepage UTF8}
VAR VentasBrutas:integer;
    salario:double;
    n,c,i:integer;
    contadores:array[1..9] of integer;    
BEGIN
 Write('Ingrese numero de Vendedores : ');Readln(n);
 For i:= 1 to n do
  Begin
    Write('Ventas Vendedor [',i,'] : ');Readln(VentasBrutas);
    Salario:=200+(0.09*VentasBrutas);
    if (salario>=200) and (salario<=299) then contadores[1]:=contadores[1]+1
    else if (salario<=399) then contadores[2]:=contadores[2]+1
    else if (salario<=499) then contadores[3]:=contadores[3]+1
    else if (salario<=599) then contadores[4]:=contadores[4]+1
    else if (salario<=699) then contadores[5]:=contadores[5]+1
    else if (salario<=799) then contadores[6]:=contadores[6]+1
    else if (salario<=899) then contadores[7]:=contadores[7]+1
    else if (salario<=999) then contadores[8]:=contadores[8]+1
    else contadores[9]:=contadores[9]+1;
  End;
 c:=200;
 For i:= 1 to 9 do
   Begin
     if c<>1000 then Writeln('[',c,'..',c+99,']: ',contadores[i])
                else Writeln('[',c,'..]: ',contadores[i]);
     c:=c+100;
   End;
 Write('Presione enter para terminar ...');
 Readln
END.
   

B)

 

 
{$codepage UTF8}
VAR MA,MB,MR:array [1..10,1..10] of double;
    i,j,n:integer;
BEGIN  
  Write('Introduzca longitud de la Matriz : ');
  Readln(n);
  Writeln('Ingrese datos de la primera Matriz : ');
  for i:= 1 to n do
   Begin
    for j:=1 to n do
      Begin
        Write('[',i,',',j,'] ');Read(MA[i,j]);       
      End;
    Writeln  
   End;   
  Writeln('Ingrese datos de la segunda Matriz : ');
  for i:= 1 to n do
   Begin
    for j:=1 to n do
      Begin
        Write('[',i,',',j,'] ');Read(MB[i,j]);       
      End;
      Writeln;
   End;     
  for i:= 1 to n do
    for j:= 1 to n do
        MR[i,j]:=MA[i,j]+MB[i,j];
        
  Writeln('Resulatdo de la suma ');      
  for i:= 1 to n do
    Begin
     for j:= 1 to n do
      Begin
        Write('[',i,',',j,'] : ',MR[i,j]:2:2,' ');
      End;
     Writeln;
    End;
  Write('Presione Enter para terminar ...');
  Readln;
  Readln
END.
   

C)

 

 
{$codepage UTF8}
VAR MA,MB,MR:array [1..10,1..10] of double;
    i,j,k,n:integer;
BEGIN
  Write('Introduzca longitud de la Matriz : ');
  Readln(n);
  Writeln('Ingrese datos de la primera Matriz : ');
  for i:= 1 to n do
   Begin
    for j:=1 to n do
      Begin
        Write('[',i,',',j,']');Read(MA[i,j]);
      End;
    Writeln
   End;
  Writeln('Ingrese datos de la segunda Matriz : ');
  for i:= 1 to n do
   Begin
    for j:=1 to n do
      Begin
        Write('[',i,',',j,']');Read(MB[i,j]);
      End;
      Writeln;
   End;

  for i:= 1 to n do
    for j:= 1 to n do
      Begin
        MR[i,j]:=0;
        for k:=1 to n do
          MR[i,j]:=MR[i,j]+MA[i,k]*MB[k,j];
      End;

  Writeln('Resultado del producto');
  for i:= 1 to n do
    Begin
     for j:= 1 to n do
      Begin
        Write('[',i,',',j,'] : ',MR[i,j]:2:3);
      End;
     Writeln;
    End;
  Write('Presione Enter para terminar ...');
  Readln;
  Readln
END.
   

D)

 

 
{$codepage UTF8}
VAR Ventas:array[1..5,1..6] of real; 
    i,j,n,k :integer;
    Vnt : real;
BEGIN
  Write('Reportes a procesar ');Readln(n);
  for k:=1 to n do
    Begin
      Write('# vendedor : ');Readln(i);
      Write('# producto : ');Readln(j);
      Write('Ventas      : ');Readln(Vnt);
      Ventas[i,j]:=Ventas[i,j]+Vnt;      
    End;
//Obtener totales
  for i:=1 to 4 do
   for j:= 1 to 5 do
    Ventas[i,6]:=Ventas[i,6]+Ventas[i,j];

  for i:=1 to 4 do
   for j:= 1 to 5 do
    Ventas[5,j]:=Ventas[5,j]+Ventas[i,j];
    
  Writeln;              
  Writeln('Totales ');  
  Writeln('Vend\Prod        1        2        3        4        5    total');
  for i:=1 to 5 do
    Begin
     if i<>5 then Write('      ',i,'   ')
             else Write('total     ');                    
     for j:= 1 to 6 do  Write(Ventas[i,j]:8:2,' ');
     Writeln;
    End;
  Writeln;
  Write('Presione Enter para terminar ...');Readln
END.
   

E)

 

 
{$codepage UTF8}
VAR Matriz:array [1..30,1..30] of integer;
    d1,d2,i,j :integer;
    posi1,posj1,posi2,posj2: integer;
    mayor : integer = -32768;
    menor : integer = 32767;
BEGIN
  Writeln('Ingrese dimensiones de la matriz (maximo 30 x 30 ): ');  
  Write('d1 : ');Readln(d1);
  Write('d2 : ');Readln(d2);
  Writeln('Ingrese datos a la matriz');
  for i:= 1 to d1 do
   for j:= 1 to d2 do
     Begin
       Write('matriz [',i,',',j,']');
       Readln(Matriz[i,j]);
     End;
  Writeln('Matriz');
  for i:= 1 to d1 do
   Begin
     for j:= 1 to d2 do
       Write(Matriz[i,j]:5);
     Writeln;  
   End; 
   
  for i:= 1 to d1 do
   for j:= 1 to d2 do
     Begin
       if matriz[i,j] > mayor then Begin
                                   posi1:=i;
                                   posj1:=j;
                                   mayor:=matriz[i,j];
                                 End;  
       if matriz[i,j] < menor then Begin
                                   Writeln(i,j);
                                   menor:=matriz[i,j];
                                   posi2:=i;
                                   posj2:=j;
                                 End;  
     End;
  Writeln('El mayor es : [',posi1,',',posj1,'] = ',mayor);
  Writeln('El menor es : [',posi2,',',posj2,'] = ',menor);
  Writeln('Presione Enter para terminar ...');
  Readln
END.
     

F)

 

 
{$codepage UTF8}
VAR Ventas:array[1..11,1..16] of integer; 
    i,j,n,k,Vnt:integer;
    vendedor,automovil:integer;
    mayor:integer = -65536;
BEGIN
  Write('¿Cuantos Entradas va a procesar?');Readln(n);
  for k:=1 to n do
    Begin
      Write('Nº vendedor           : ');Readln(i);
      Write('Nº modelo             : ');Readln(j);
      Write('Automoviles vendidos  : ');Readln(Vnt);
      Ventas[i,j]:=Ventas[i,j]+Vnt;
    End;
//Obtener totales
  for i:=1 to 10 do
   for j:= 1 to 15 do
    Ventas[i,16]:=Ventas[i,16]+Ventas[i,j];

  for i:=1 to 10 do
   for j:= 1 to 15 do
    Ventas[11,j]:=Ventas[11,j]+Ventas[i,j];
  Writeln;              
  Writeln('Totales ');  
  Writeln('Vend\Auto  1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  total');
  for i:=1 to 11 do
    Begin
     if i<>11 then Write('    ',i:2,'  ')
              else Write('total   '); 
     for j:= 1 to 16 do
      Begin
        Write(Ventas[i,j]:4);
      End;
     Writeln;
    End;    
  for i:= 1 to 10 do
   for j:= 1 to 15 do
     Begin
       if Ventas[i,j]>mayor then
          Begin
            mayor:=Ventas[i,j];
            vendedor:=i;
            automovil:=j;
          End;
     End;    
  Writeln('El vendedor que vendio mas autos es el numero : ',vendedor);
  Writeln('Vendio un total de : ',mayor,' automoviles');
  Writeln('El modelo que más vendio es el numero :',automovil);
  Writeln;
  Write('Presione Enter para terminar ...');Readln
END. 
     

G)

 

 
{$codepage UTF8}
VAR  ni,hi,NiMenorQ,NiMayorQ,HiMenorQ,HiMayorQ:array[1..100] of real;     
     n,i:integer;
     Tni:real = 0;  
BEGIN  
  Write('Ingrese numero de datos : ');readln(n);
  for i:= 1 to  n do
   Begin
     Write('ni[',i,'] '); readln(ni[i]);
     Tni+=ni[i];
   End;
  
  //Frecuencia Relativa hi
  for i:= 1 to n do  hi[i]:=ni[i]/Tni;    
    
  //Frecuencia Absoluta Acumulada Menor Que Ni
  NiMenorQ[1]:=ni[1];
  for i:=2 to n do  NiMenorQ[i]:=NiMenorQ[i-1]+ni[i];
  
  //Frecuencia Absoluta Acumulada Mayor Que Ni*
  NiMayorQ[1]:=Tni;
  for i:=2 to n do  NiMayorQ[i]:=NiMayorQ[i-1]-ni[i-1];  
  
  //Frecuencia Relativa Acumulada Menor Que Hi
  HiMenorQ[1]:=hi[1];
  for i:=2 to n do  HiMenorQ[i]:=HiMenorQ[i-1]+hi[i];

  //Frecuencia Relativa Acumulada Mayor Que Hi*
  HiMayorQ[1]:=1;
  for i:=2 to n do  HiMayorQ[i]:=HiMayorQ[i-1]-hi[i-1];    
  
  Writeln('     ni      hi      Ni      Ni*     Hi      Hi*');
  for i:=1 to n do 
    Writeln(ni[i]:8:2,hi[i]:8:2,NiMenorQ[i]:8:2,
    NiMayorQ[i]:8:2,HiMenorQ[i]:8:2,HiMayorQ[i]:8:2);       
  Writeln;         
  Write('Presione Enter para terminar ...');Readln
END.
     

H)

 

 
{$codepage UTF8}
USES math; 
CONST maximo=1000;
VAR numeros:array[1..maximo] of boolean;
    i,j,m,n:word; 
BEGIN
 Write('Ingrese un numero menor a 1000 : ');readln(n);
 if (n < maximo) then
  Begin
   for i:=1 to n do numeros[i]:=true; 
   m:=trunc(n**(1/2));
   for i:=2 to m do
     if numeros[i] then for j:=2 to n div i do numeros[i*j]:=false;
   for i:=1 to n do if numeros[i] then writeln(i:4);
  End   
END.

 

   

6.

 

Cree los programas que se describen a continuación (cadenas):

 

   

 

 

A)

 
{$codepage UTF8}
VAR Cad,cad2:String;
    i : integer;
    blanco:boolean=false;    
BEGIN
  Write('Ingrese una cadena : ');Readln(Cad);   
  for i:= 1 to length(Cad) do
   Begin
     if cad[i]<>' ' then
        Begin
          cad2:=cad2+cad[i];
          blanco:=true
        End
     else
        if blanco then Begin
                         cad2:=cad2+' ';
                         blanco:=false
                       End;
   End;
  cad2[0]:=chr(length(cad2)-1); 
  Write('Cadena 2 : |',cad2,'|');
  Readln
END.
     

B)

 
{$codepage UTF8}
TYPE TVocales =(a,e,i,o,u);
VAR Cad:String;
    j:integer;
    Vocales : array [TVocales] of integer;
BEGIN
  Write('Ingrese un texto : ');Readln(Cad);
  For j := 1 to length(cad) do
    Begin       
      if Cad[j] in ['a','A',#160] then Vocales[a]+=1;
      if Cad[j] in ['e','E',#130] then Vocales[e]+=1;
      if Cad[j] in ['i','I',#161] then Vocales[i]+=1;
      if Cad[j] in ['o','O',#162] then Vocales[o]+=1;
      if Cad[j] in ['u','U',#163] then Vocales[u]+=1;                                   
    End;
  Write('a :',Vocales[a]:4,' ');
  For j:=1 to Vocales[a] do Write('*');Writeln;
  Write('e :',Vocales[e]:4,' ');
  For j:=1 to Vocales[e] do Write('*');Writeln;
  Write('i :',Vocales[i]:4,' ');
  For j:=1 to Vocales[i] do Write('*');Writeln;
  Write('o :',Vocales[o]:4,' ');
  For j:=1 to Vocales[o] do Write('*');Writeln;
  Write('u :',Vocales[u]:4,' ');
  For j:=1 to Vocales[u] do Write('*');Writeln;
  Readln
END.
     

C)

 

 
{$codepage UTF8}
VAR Cad,Cad2:String;
    der,i,j:integer;
BEGIN
 Write('Ingrese un cadena : ');Readln(Cad);
 Write('Caracteres a tomar por la derecha : ');Readln(der);
 j:=(length(cad)-der)+1;
 for i:=j to length(cad) do cad2:=cad2+cad[i];
 Writeln('Caracteres de la derecha : ',cad2);
 Write('Presione enter para terminar ...');Readln;
END.
     

D)

 

 
{$codepage UTF8}
VAR Cad,Cad2:String;
    izq,i:integer;
BEGIN
 Write('Ingrese un cadena : ');Readln(Cad);
 Write('Caracteres a tomar por la izquierda : ');Readln(izq); 
 for i:=1 to izq do cad2:=cad2+cad[i];
 Writeln('Caracteres de la izquierda : ',cad2);
 Write('Presione enter para terminar ...');Readln;
END.
     

E)

 

 
{$codepage UTF8}
VAR Cad:String;
    i,j:byte;    
    Letras : array [1..27] of integer;
BEGIN
 Write('Ingrese una frase : ');Readln(Cad);
 for i:=1 to length(Cad) do
   Begin 
     Case Cad[i] of   
       'a','A',#160 : Letras[1]+=1;
       'b','B' : Letras[2]+=1;
       'c','C' : Letras[3]+=1;
       'd','D' : Letras[4]+=1;
       'e','E',#130 : Letras[5]+=1;
       'f','F' : Letras[6]+=1;
       'g','G' : Letras[7]+=1;
       'h','H' : Letras[8]+=1;
       'i','I',#161 : Letras[9]+=1;
       'j','J' : Letras[10]+=1;
       'k','K' : Letras[11]+=1;
       'l','L' : Letras[12]+=1;
       'm','M' : Letras[13]+=1;
       'n','N' : Letras[14]+=1;
       #164,#165 : Letras[15]+=1;
       'o','O',#162 : Letras[16]+=1;
       'p','P' : Letras[17]+=1;
       'q','Q' : Letras[18]+=1;
       'r','R' : Letras[19]+=1;
       's','S' : Letras[20]+=1;
       't','T' : Letras[21]+=1;
       'u','U' : Letras[22]+=1;
       'v','V' : Letras[23]+=1;
       'w','W' : Letras[24]+=1;
       'x','X' : Letras[25]+=1;
       'y','Y' : Letras[26]+=1;
       'z','Z' : Letras[27]+=1;
     End;     
   End;  
 j:=65;   
 for i:=1 to 14 do
  Begin    
    Writeln('letra ',chr(j),' : ',Letras[i]);
    j+=1;
  End;
 Writeln('letra '+#165+' : ',Letras[15]);    
 j:=79;
 for i:=16 to 27 do
  Begin    
    Writeln('letra ',chr(j),' : ',Letras[i]);
    j+=1;
  End;
 Write('Presione enter para terminar ...');Readln;
END.
     

F)

 

 
{$codepage UTF8}
VAR Cad,Cadaux:String;
    contar:Boolean=false;
    contadores:array [1..22] of integer;    
    i:integer;
BEGIN
 Write('Ingrese un frase : ');Readln(Cad); 
 cad:=cad+' ';
 For i:= 1 to length(Cad) do
   Begin
     if Cad[i]<>' ' then
       Begin
         cadaux:=cadaux+cad[i];
         contar:=true;
       End
     else
       Begin
         if contar then
            Begin
             contadores[length(cadaux)]+=1;          
             contar:=false;
            End;
         cadaux:='';   
       End;  
   End; 
 For i:=1 to 22 do Writeln('palabras de ',i,' letra : ',contadores[i]:4);   
 Write('Presione Enter...');Readln;
END.

 

   

7.

 

Cree los programas que se describen a continuación (Registros):

 

   

 

 

A)

 
{$codepage UTF8}
USES math;
TYPE Punto=Record
             x,y:double
           End;  
VAR
  p1,p2:TPunto;
  longitud,pendiente:double;   
BEGIN
  Writeln('Ingrese cordenadas del 1er punto ');
  Write('x1 : ');Readln(p1.x);
  Write('y1 : ');Readln(p1.y);  
  Writeln('Ingrese cordenadas del 2do punto ');
  Write('x2 : ');Readln(p2.x);
  Write('y2 : ');Readln(p2.y);  
  
  longitud:=(p2.x-p1.x)**2;
  longitud:=longitud+((p2.y-p1.y)**2);  
  longitud:=longitud**(1/2);  
  
  pendiente:=(p2.y-p1.y)/(p2.x-p1.x);
  Writeln('su longitud es  : ',longitud:4:4);
  Writeln('su pendiente es : ',pendiente:4:4);
  Write('Presione enter para terminar ...');
  Readln
END.
     

B)

 

 
{$codepage UTF8}
USES math;
VAR
 figuras : Record
             area:double;
             Case tipo:char of
              'T':(lado1,lado2,lado3,p:double);
              'R':(longitudR,anchura:double);
              'C':(longitudC:double);
              'X':(radio:double);
           End;
 tipo:char;          
BEGIN
 Write('Selecione una figura (T)riangulo (R)ectangulo (C)uadrado (X)Circulo : ');
 Readln(tipo);
 Case tipo of
   'T','t' : Begin
               figuras.tipo:='T';  
               Write('lado1 : ');Readln(figuras.lado1);
               Write('lado2 : ');Readln(figuras.lado2);
               Write('lado3 : ');Readln(figuras.lado3);               
               figuras.p:=(figuras.lado1+figuras.lado2+figuras.lado3)/2;
               figuras.area:= figuras.p*((figuras.p-figuras.lado1)*
                              (figuras.p-figuras.lado2)*(figuras.p-figuras.lado3));
               figuras.area:=figuras.area**(1/2);
               Writeln('area : ',figuras.area:4:4);
             End;
   'R','r' : Begin
              figuras.tipo:='R';
              Write('longitud : ');Readln(figuras.longitudR);
              Write('Anchura  : ');Readln(figuras.Anchura);
              figuras.area:=figuras.longitudR*figuras.anchura;              
              Writeln('area : ',figuras.area:4:4);
             End;
   'C','c' : Begin
              figuras.tipo:='C';
              Write('longitud : ');Readln(figuras.longitudC);
              figuras.area:=figuras.longitudC**2;
              Writeln('area : ',figuras.area:4:4);
             End;
   'X','x' : Begin
              figuras.tipo:='X';
              Write('radio : ');Readln(figuras.radio);
              figuras.area:=3.141592*(figuras.radio**2);
              Writeln('area : ',figuras.area:4:4);
             End;
 End;
 Write('Presione Enter para terminar ...');
 Readln
END.
     

C)

 

 
{$codepage UTF8}
TYPE TPersona = Record
                 Nombre       : String;
                 Edad         : String;
                 Sexo         : Char;
                 altura       : double;
                 colorpiel    : String;
                 colorojos    : String;
                 nacionalidad : String;
                 region       : String;
               End;
VAR personas : array [1..65536] of TPersona;
    i,j,n:integer;    
    aux:Tpersona;
BEGIN  
  Write('Ingrese numero de registros a procesar : ');Readln(n);
  for i:=1 to n do
    Begin
      Writeln('Registro #',i);
      Write('Nombre       : ');Readln(personas[i].Nombre);
      Write('Edad         : ');Readln(personas[i].Edad);
      Write('Sexo         : ');Readln(personas[i].Sexo);
      Write('Altura       : ');Readln(personas[i].Altura);
      Write('Color Piel   : ');Readln(personas[i].ColorPiel);
      Write('Color Ojos   : ');Readln(personas[i].ColorOjos);
      Write('Nacionalidad : ');Readln(personas[i].Nacionalidad);
      Write('Region       : ');Readln(personas[i].Region);
    End;
    
  Writeln('ordenando');  
  For i:=2 to n do  
    Begin
       aux:=personas[i];
       j:=i-1;
       While ( (j>=1) and (personas[j].Nombre>aux.Nombre) ) do 
          Begin
             personas[j+1]:= personas[j]; 
             j := j - 1;                    
          End;
        personas[j+1]:=aux; 
    End;  
  
  Writeln('Mostrando arreglo ordenado');
  for i:=1 to n do
    Begin
      Writeln('Registro #',i);
      Writeln('Nombre       : ',personas[i].Nombre);
      Writeln('Edad         : ',personas[i].Edad);
      Writeln('Sexo         : ',personas[i].Sexo);
      Writeln('Altura       : ',personas[i].Altura:4:2);
      Writeln('Color Piel   : ',personas[i].ColorPiel);
      Writeln('Color Ojos   : ',personas[i].ColorOjos);
      Writeln('Nacionalidad : ',personas[i].Nacionalidad);
      Writeln('Region       : ',personas[i].Region);
    End;
  Write('Presione enter para terminar ...');
  Readln;  
END. 
     

D)

 

 
{$codepage UTF8}
TYPE TAlumno = Record
                 Nombre       : String;
                 nota1,nota2,nota3,nota4,nota5 : double;
                 notapromedio : double;
                 estado:string;
               End;
VAR Alumnos : array [1..65536] of TAlumno;
    i,n:integer;      
BEGIN  
  Write('Ingrese numero de registros a procesar : ');Readln(n);
  for i:=1 to n do
    Begin
      Writeln('Registro #',i);
      With Alumnos[i] do
        Begin
          Write('Nombre   : ');Readln(Nombre);
          Write('nota1    : ');Readln(nota1);
          Write('nota2    : ');Readln(nota2);
          Write('nota3    : ');Readln(nota3);
          Write('nota4    : ');Readln(nota4);
          Write('nota5    : ');Readln(nota5);
          notapromedio:=(nota1+nota2+nota3+nota4+nota5)/5;
          if (notapromedio>10) then estado:='APROBADO'
                               else estado:='DESAPROBADO'
        End;                        
    End;
   
  Writeln('Alumnos desaprobados');
  Writeln('Nombre      nota promedio');
  for i:=1 to n do  
    Begin
      if (Alumnos[i].estado='DESAPROBADO')
        then Writeln(Alumnos[i].Nombre:8,Alumnos[i].notapromedio:10:2);
    End;  
  Write('Presione enter para terminar ...');
  Readln;  
END. 

 

   

8.

 

Cree los programas que se describen a continuación (Conjuntos):

 

   

 

 

A)

 
{$codepage UTF8}
VAR Cad : String;
    ConjMayus: Set of Char;
    i : integer;
BEGIN
  ConjMayus:=[];
  Write('Ingrese una cadena de caracteres : ');Readln(cad);
  for i:=1 to length(cad)  do
    Begin
      if cad[i] in ['A'..'Z',#165] then
         ConjMayus:=ConjMayus + [cad[i]];
    End;       
  for i:=1 to 255 do
    Begin
      if chr(i) in ConjMayus then Begin
                                  write(chr(i),',');
                                  ConjMayus:=ConjMayus-[chr(i)]
                                End;      
    End;
  Writeln;         
  Writeln('Presione enter para terminar ...');
  Readln
END.
     

B)

 

 
{$codepage UTF8}
VAR Cad : String;
    Vocales,Consonantes : Set of Char;
    i : integer;
BEGIN
  Vocales:=[];
  Consonantes:=[];
  Write('Ingrese una cadena de caracteres : ');Readln(cad);
  for i:= 1 to length(cad) do
    Begin 
      if cad[i] = #160 then cad[i]:='a';
      if cad[i] = #130 then cad[i]:='e';
      if cad[i] = #161 then cad[i]:='i';      
      if cad[i] = #162 then cad[i]:='o';      
      if cad[i] = #163 then cad[i]:='u';                        
    End;
  for i:=1 to length(cad)  do
    Begin
      if cad[i] in ['a','e','i','o','u','A','E','I','O','U'] then
         Vocales:=Vocales + [cad[i]]
         else if cad[i] in ['A'..'Z',#165,'a'..'z',#164] then
           Consonantes:=Consonantes+[cad[i]]
    End;
  Writeln('Vocales');
  for i:= 1 to 255 do
    Begin
      if chr(i) in vocales then Begin
                                  write(chr(i),',');
                                  Vocales:=Vocales-[chr(i)]
                                End;  
    End;  
  Writeln;  
  Writeln('Consonantes');
  for i:= 1 to 255 do
    Begin
      if chr(i) in Consonantes then Begin
                                  write(chr(i),',');
                                  Consonantes:=Consonantes-[chr(i)]
                                End;  
    End;
 Writeln;         
 Writeln('Presione enter para terminar ...');
 Readln
END.
     

anterior :: indice :: siguiente

 

 
 

  SUGERENCIAS