Описать и ввести в массив, содержащий 5 записей следующей структуры фамилия, имя, пол, возраст, кем приходится, дата рождения. Вывести массив в табличном виде. Вывести списки родственников в алфавитном порядке, затем найти самого молодого родственника.- QBasic(Бейсик)

CLS
TYPE rodnya
    f AS STRING * 20
    n AS STRING * 10
    p AS STRING * 5
    v AS INTEGER
    k AS STRING * 20
    d AS STRING * 10
END TYPE
DIM a(5) AS rodnya
DATA "Ivanov","Ivan","m",40,"brat","20.04.70"
DATA "Petrov","petr","m",23,"kuzin","14.03.87"
DATA "Suvorov","Semen","m",43,"otec","25.12.67"
DATA "Kuznecova","Lena","zh",25,"zhena","28.12.84"
DATA "Soboleva","Olga","zh",32,"sestra","15.12.78"
FOR i = 1 TO 5
    READ a(i).f
    READ a(i).n
    READ a(i).p
    READ a(i).v
    READ a(i).k
    READ a(i).d
NEXT i
PRINT "Familiya"; TAB(21); "Imya"; "     "; "Pol";
PRINT "   vozr"; " kem prihoditsya"; "    data rozhden"
PRINT
FOR i = 1 TO 5
    PRINT a(i).f; a(i).n; a(i).p; a(i).v; "  "; a(i).k; a(i).d
NEXT i
FOR i = 1 TO 5
    FOR j = i + 1 TO 5
        FOR l = 1 TO LEN(a(i).f)
            b1$ = MID$(a(i).f, l, 1): b2$ = MID$(a(j).f, l, 1)
            IF b1$ > b2$ THEN
                SWAP a(i), a(j)
                EXIT FOR
            ELSEIF b1$ < b2$ THEN EXIT FOR
            END IF
        NEXT l
    NEXT j
NEXT i
PRINT
PRINT "Familii rodstvennikov v alfavitnom poryadke"
PRINT
FOR i = 1 TO 5
    PRINT a(i).f
NEXT i
min = a(1).v: mini = 1
FOR i = 2 TO 5
    IF a(i).v < min THEN min = a(i).v: imin = i
NEXT i
PRINT
PRINT "Samiy molodoy rodstvennik "; a(imin).f; " "

Тестирование выполнено в программе QB64 ( Скачать )

Leave a Comment