• Lenguaje

    Pascal

  • Descripción

    Lea para un grupo de N personas el nombre, la edad y el deporte (1= fútbol, 2= baloncesto, 3= otro deporte) e imprima:
    a) cuantos de fútbol son mayores de edad
    b) cuantos de baloncesto son menores de edad
    c) cuantas personas prefieren otro deporte.

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
50
program EstadisticasDeDeportes;
uses crt;

var a, b, c, deporte, edad : integer;
var i, n : integer;
var nombre : string;
begin
    a := 0;
    b := 0;
    c := 0;
    write ('Ingresa el valor de n: ');
    readln (n);
    for i:=1 to n do
    begin
        writeln ('PROCESO ', i);
        write ('Ingresa el nombre: ');
        readln (nombre);
        write ('Ingresa el valor de edad: ');
        readln (edad);
        writeln ('Selecciona el valor de deporte.');
        writeln ('    1.- f'#163'tbol');
        writeln ('    2.- baloncesto');
        writeln ('    3.- otro deporte');
        write ('    : ');
        repeat
            readln (deporte);
            if (deporte<1) or (deporte>3) then
                write ('Valor incorrecto. Ingr'#130'salo nuevamente.: ');
        until (deporte>=1) and (deporte<=3);
        if (deporte=1) and (edad>=18) then
            begin
                a := a+1;
            end;
        if (deporte=2) and (edad<18) then
            begin
                b := b+1;
            end;
        if deporte=3 then
            begin
                c := c+1;
            end;
        writeln ('Nombre: ', nombre);
        writeln;
    end;
    writeln ('Valor de a: ', a);
    writeln ('Valor de b: ', b);
    writeln ('Valor de c: ', c);
    write ('Presiona una tecla para terminar . . . ');
    readkey;
end.