загрузка...
загрузка...
На головну

# Завдання 3 (стор.18)

Завдання 15 (стор. 19)

CLS

INPUT n, m

DIM A (n), B (m)

FOR i = 1 TO n

INPUT A (i)

NEXT i

FOR i = 1 TO m

INPUT B (i)

NEXT i

min = A (1)

KA = 1

FOR i = 2 TO n

IF A (i)

NEXT i

max = B (1)

KB = 1

FOR i = 2 TO m

IF B (i)> max THEN max = B (i): KB = i

NEXT i

SA = 0

FOR i = 1 TO n

SA = SA + A (i)

NEXT i

SB = 0

FOR i = 1 TO m

SB = SB + B (i)

NEXT i

IF SA> SB THEN SWAP B (KB), A (KA)

FOR i = 1 TO n

PRINT A (i)

NEXT i

FOR i = 1 TO m

PRINT B (i);

NEXT i

END

Завдання 3 (стор.23)

CLS

INPUT n

DIM X (n)

FOR i = 1 TO n

INPUT X (i)

NEXT i

FOR i = 1 TO n

IF X (i) <0 THEN m = i: EXIT FOR

NEXT i

S = 0

P = 1

IF m <> 0 THEN

FOR i = 1 TO m

P = P * X (i)

S = S + P

NEXT i

ELSE

FOR i = 1 TO n

P = P * X (i)

S = S + P

NEXT i

END IF

PRINT S

END

Завдання 14 (стор.24)

CLS

INPUT n

DIM A (n), B (n)

FOR i = 1 TO n

INPUT A (i)

NEXT i

FOR i = 1 TO n

IF A (i)> 0 THEN K1 = i: EXIT FOR

NEXT i

FOR i = 1 TO n

IF A (i) <0 THEN K2 = i: EXIT FOR

NEXT i

FOR i = 1 TO n

IF A (i) MOD 2 = 0 THEN B (i) = K1 * A (i) ELSE B (i) = K2 * A (i)

NEXT i

FOR i = 1 TO n

PRINT B (i);

NEXT i

END

Завдання 3 (стор.28)

CLS

INPUT n

DIM A (n)

FOR i = 1 TO n

INPUT A (i)

NEXT i

K = 0

FOR i = 1 TO n

IF A (i) MOD 2 = 0 THEN K = K + 1

IF K = 2 THEN L = i: EXIT FOR

NEXT i

IF L <> 0 THEN

FOR i = 1 TO n

A (i) = A (i) * A (L)

NEXT i

END IF

FOR i = 1 TO n

PRINT A (i);

NEXT i

END

Завдання 3 (стор. 33)

CLS

INPUT n

DIM A (n)

FOR i = 1 TO n

INPUT A (i)

NEXT i

FOR i = 1 TO n

IF A (i) MOD 2 = 0 THEN K1 = i: EXIT FOR

NEXT i

L = 0

FOR i = 1 TO n

IF A (i) MOD 2 = 0 THEN L = L + 1

IF L = 2 THEN K2 = i: EXIT FOR

NEXT i

FOR j = 1 TO K2 - K1 - 1

FOR i = K1 + 1 TO n - 1

A (i) = A (i + 1)

NEXT i

n = n - 1

NEXT j

FOR i = 1 TO n

PRINT A (i);

NEXT i

END

Завдання 3 (стор.38)

CLS

INPUT n

DIM A (n + 1)

FOR i = 1 TO n

INPUT A (i)

NEXT i

min = A (1)

L = 1

FOR i = 2 TO n

IF A (i)

NEXT i

FOR i = n TO L + 1 STEP -1

A (i + 1) = A (i)

NEXT i

A (L + 1) = 0

n = n + 1

FOR i = 1 TO n

PRINT A (i);

NEXT i

END

загрузка...
© um.co.ua - учбові матеріали та реферати