Смекни!
smekni.com

Использование ЭВМ при обучении математике (стр. 6 из 8)

curx = 0: cury = 0 'Установка начальниых координат положения стрелки

DIM colora(10)

DIM slovo$(5)

DIM zapusk$(18)

SCREEN 9, , 0, 0

OPEN filerez$ FOR APPEND AS #3

PRINT #3, DATE$; " СТАРТ ПРОГРАММЫ < СЛОЖЕНИЕ ВЕКТОРОВ > - "; TIME$;

GOSUB coord 'Построение координатной плоскости

GOSUB zapusk 'Страничка с заданиями

FOR shag = 1 TO 10

PRINT #3, : PRINT #3, "Задание - "; shag

glupo = 0

GOSUB coord 'Построение координатной плоскости

p = 1: GOSUB slov

FOR ccc = 10 TO 13 STEP 3

GOSUB telo

IF ccc = 10 THEN abx = curx - curoldx: aby = cury - curoldy ELSE cdx = curx - curoldx: cdy = cury - curoldy

NEXT ccc

PRINT #3, "AB("; abx; ","; aby; ")"; TAB(15); "; CD("; cdx; ","; cdy; ")"; " ;"; TAB(34); "m("; cdx + abx; ", "; cdy + aby; ")";

GOSUB analis

NEXT shag

GOSUB coord

LOCATE 10, 53: PRINT "Вы допустили "; oshibka; " ошибок"

PRINT #3,

PRINT #3, "Количество допущенных ошибок - "; oshibka

PRINT #3,

CLOSE #3

DO WHILE INKEY$ = "": LOOP

GOTO alis

telo:

GOSUB preobr:

GOSUB zapomin ' Запоминает

GOSUB strelka ' Рисует стрелку

GOSUB vibor '

GOSUB oldstrelka ' Закрашивает место, где была стрелка

IF fl = 2 THEN fl = 0: RETURN

GOTO telo

vibor:

flag = 0

kbd$ = INKEY$

SELECT CASE kbd$

CASE CHR$(0) + "H": IF cury < 10 THEN cury = cury + 1: flag = 1

CASE CHR$(0) + "P": IF cury > -10 THEN cury = cury - 1: flag = 1

CASE CHR$(0) + "K": IF curx > -11 THEN curx = curx - 1: flag = 1

CASE CHR$(0) + "M": IF curx < 11 THEN curx = curx + 1: flag = 1

CASE CHR$(0) + CHR$(59): GOSUB reklama

CASE CHR$(32): GOSUB final: IF fl = 2 THEN RETURN

CASE CHR$(27): GOSUB vihod

END SELECT

IF flag = 0 THEN GOTO vibor

kx = x: ky = y

GOSUB preobr

RETURN

strelka:

'==== x y c ============ Рисует стрелку ========

PSET (x, y), c

DRAW "r6g2f4g2h4g2u6"

PAINT (x + 1, y + 1), c

PSET (x, y), 15

DRAW "r6g2f4g2"

RETURN

zapomin:

'==== x y ============ zap(9,9) ========

DIM zap(9, 9)

FOR i = 1 TO 9

FOR j = 1 TO 9

zap(i, j) = POINT(i + x - 1, j + y - 1)

NEXT j

NEXT i

RETURN

oldstrelka:

'==== kx ky zap(9,9) ==== Рисует ====

FOR i = 1 TO 9

FOR j = 1 TO 9

PSET (i + kx - 1, j + ky - 1), zap(i, j)

NEXT j

NEXT i

ERASE zap

RETURN

preobr:

x = curx * 16 + 203

y = 160 - cury * 14

RETURN

final:

kx = x: ky = y: GOSUB oldstrelka

IF fl = 1 THEN x2 = x: y2 = y: GOSUB strvect: IF ccc = 10 THEN p = 2: GOSUB slov ELSE p = 5: GOSUB slov

IF fl = 0 THEN curoldx = curx: curoldy = cury: x1 = x: y1 = y: CIRCLE (x, y), radius, ccc: IF zakr = 1 THEN PAINT (x, y), ccc

IF ccc = 10 AND fl = 0 THEN p = 3: GOSUB slov

IF ccc = 13 AND fl = 0 THEN p = 4: GOSUB slov

IF ccc = 14 AND fl = 0 THEN p = 6: GOSUB slov

fl = fl + 1

GOSUB zapomin: GOSUB strelka: RETURN

coord:

COLOR 15: CLS

'LINE (0, 0)-(639, 349), 15, B

LINE (10, 10)-(395, 311), 15, B

LINE (10, 10)-(394, 310), 7, B

LINE (400, 10)-(629, 311), 15, B

LINE (400, 10)-(628, 310), 7, B

FOR g = 27 TO 380 STEP 16

LINE (g, 15)-(g, 305), 8, B

NEXT g

FOR g = 20 TO 300 STEP 14

LINE (19, g)-(387, g), 8, B

NEXT g

FOR g = -10 TO 10 STEP 2

LOCATE 13, g * 2 + 25

IF g <> 0 THEN PRINT g

NEXT g

FOR g = -10 TO 10 STEP 2

LOCATE 12 - g, 24

PRINT g

NEXT g

LINE (19, 160)-(387, 160), 7, B

LINE (384, 158)-(387, 160), 7

LINE (384, 162)-(387, 160), 7

LINE (203, 15)-(203, 305), 7, B

LINE (200, 18)-(203, 15), 7

LINE (206, 18)-(203, 15), 7

LOCATE 2, 28

PRINT "y"

LOCATE 11, 49

PRINT "x"

shar:

FOR c = 1 TO 10

CIRCLE (405 + c * 20, 41), 7, 15

LINE (405 + c * 20, 38)-(410 + c * 20, 31), 15

PAINT (405 + c * 20, 39), colora(c), 15

NEXT c

RETURN

strvect:

dx = SQR((x2 - x1) ^ 2)

dy = SQR((y2 - y1) ^ 2)

df = SQR((dx * dx) + (dy * dy))

IF df = 0 THEN df = 1

dsx = k * dx / df

dsy = k * dy / df

dxx = k1 * dy / df

dyy = k1 * dx / df

IF x1 < x2 THEN x3 = x2 - dsx: x4 = x2 - dsx / 2 ELSE x3 = x2 + dsx: x4 = x2 + dsx / 2

IF y1 < y2 THEN y3 = y2 - dsy: y4 = y2 - dsy / 2 ELSE y3 = y2 + dsy: y4 = y2 + dsy / 2

IF SGN(x1 - x2) = SGN(y1 - y2) THEN x31 = x3 - dxx: y31 = y3 + dyy: x32 = x3 + dxx: y32 = y3 - dyy

IF SGN(x1 - x2) * (-1) = SGN(y1 - y2) THEN x31 = x3 + dxx: y31 = y3 + dyy: x32 = x3 - dxx: y32 = y3 - dyy

IF SGN(x1 - x2) = 0 OR SGN(y1 - y2) = 0 THEN x31 = x3 - dxx: y31 = y3 - dyy: x32 = x3 + dxx: y32 = y3 + dyy

LINE (x31, y31)-(x2, y2), ccc

LINE (x32, y32)-(x2, y2), ccc

IF zakrstr = 1 THEN LINE (x32, y32)-(x31, y31), ccc: PAINT (x4, y4), ccc

LINE (x1, y1)-(x2, y2), ccc

RETURN

reklama:

SCREEN 9, , 1, 1

COLOR 7, 0

OPEN FILEHLP$ FOR INPUT AS #1

S = 0

DO

ON ERROR GOTO 0

LINE INPUT #1, stran$

S = S + 1

LOOP UNTIL EOF(1)

CLOSE #1

IF FIX(S / 18) >= (S / 18) THEN KS = FIX(S / 18) ELSE KS = FIX(S / 18) + 1

DIM stran$(S)

OPEN FILEHLP$ FOR INPUT AS #1

FOR i = 1 TO S

ON ERROR GOTO 0

LINE INPUT #1, stran$(i)

NEXT i

CLOSE #1

NS = 1

GOSUB stran

obrabotka:

a$ = INKEY$

IF a$ = CHR$(0) + CHR$(73) THEN NS = NS - 1: GOSUB stran

IF a$ = CHR$(0) + CHR$(81) THEN NS = NS + 1: GOSUB stran

IF a$ = CHR$(27) THEN ERASE stran$: SCREEN 9, , 0, 0: RETURN

GOTO obrabotka

stran:

IF NS < 1 THEN NS = 1: RETURN

IF NS > KS THEN NS = KS: RETURN

n = 18 * NS

LOCATE 1, 1

PRINT "г"; STRING$(64, "="); "T=============¬"

PRINT "¦"; STRING$(15, " "); : COLOR 15, 0: PRINT "ИНФОРМАЦИОННО - СПРАВОЧНАЯ СИСТЕМА"; : COLOR 7, 0: PRINT STRING$(15, " ");

IF NS < 10 THEN PRINT "¦ Страница "; NS; "¦" ELSE PRINT "¦ Страница"; NS; "¦"

PRINT "¦"; STRING$(64, " "); "L=============¦"

FOR i = n - 17 TO n

IF i > S THEN PRINT "¦"; STRING$(78, " "); "¦" ELSE PRINT "¦ "; stran$(i); STRING$((76 - LEN(stran$(i))), " "); "¦"

NEXT i

PRINT "L"; STRING$(78, "="); "-"

'COLOR 1, 7:

PRINT " Выход - Esc ";

'IF NS = 1 THEN COLOR 8, 7 ELSE COLOR 1, 7

PRINT " Предыдущая страница - PageUp ";

'IF NS = KS THEN COLOR 8, 7 ELSE COLOR 1, 7

PRINT " Следующая страница - PageDown "

COLOR 7, 0

RETURN

analis:

PRINT #3,

PRINT #3, "Варианты ответов ученика:";

ccc = 10

COLOR ccc

LOCATE 9, 58: PRINT "__"

LOCATE 10, 58: PRINT "AB ( ; )"

PRINT #3,

PRINT #3, "координата x вектора AB ";

vectx1:

p = 11: GOSUB slov

mm = 3: nx = 10: ny = 63

l$ = "+-1234567890"

m$ = "": m = 0

GOSUB napis

PRINT #3, VAL(m$);

IF abx <> VAL(m$) THEN GOSUB glupo: GOTO vectx1

PRINT #3,

PRINT #3, "координата y вектора AB ";

vecty1:

p = 12: GOSUB slov

mm = 3: nx = 10: ny = 69

l$ = "+-1234567890"

m$ = "": m = 0

GOSUB napis

PRINT #3, VAL(m$);

IF aby <> VAL(m$) THEN GOSUB glupo: GOTO vecty1

ccc = 13

COLOR ccc

LOCATE 11, 58: PRINT "__"

LOCATE 12, 58: PRINT "CD ( ; )"

PRINT #3,

PRINT #3, "координата x вектора CD ";

vectx2:

p = 13: GOSUB slov

mm = 3: nx = 12: ny = 63

l$ = "+-1234567890"

m$ = "": m = 0

GOSUB napis

PRINT #3, VAL(m$);

IF cdx <> VAL(m$) THEN GOSUB glupo: GOTO vectx2

PRINT #3,

PRINT #3, "координата y вектора CD ";

vecty2:

p = 14: GOSUB slov

mm = 3: nx = 12: ny = 69

l$ = "+-1234567890"

m$ = "": m = 0

GOSUB napis

PRINT #3, VAL(m$);

IF cdy <> VAL(m$) THEN GOSUB glupo: GOTO vecty2

ccc = 14

COLOR ccc

LOCATE 13, 53: PRINT "__ __ _"

LOCATE 14, 53: PRINT "AB+CD=m ( ; )"

PRINT #3,

PRINT #3, "координата x вектора m ";

vectx3:

p = 15: GOSUB slov

mm = 3: nx = 14: ny = 63

l$ = "+-1234567890"

m$ = "": m = 0

GOSUB napis

PRINT #3, VAL(m$);

IF cdx + abx <> VAL(m$) THEN GOSUB glupo: GOTO vectx3

PRINT #3,

PRINT #3, "координата y вектора m ";

vecty3:

p = 16: GOSUB slov

mm = 3: nx = 14: ny = 69

l$ = "+-1234567890"

m$ = "": m = 0

GOSUB napis

PRINT #3, VAL(m$);

IF cdy + aby <> VAL(m$) THEN GOSUB glupo: GOTO vecty3

ccc = 14: p = 5: GOSUB slov

vectm:

GOSUB telo

'Обработка ошибки правильности построения вектора m

mmx = curx - curoldx: mmy = cury - curoldy

IF mmx <> abx + cdx OR mmy <> aby + cdy THEN GOSUB glupo: PRINT #3, : PRINT #3, "Построил вектор m("; mmx; ","; mmy; ")"; : CIRCLE (x1, y1), radius, 12: ccccc = ccc: ccc = 12: GOSUB strvect: ccc = ccccc: GOTO vectm

p = 20: GOSUB slov

IF glupo = 0 THEN colora(shag) = 4: coob$ = " Нет ошибок ": GOSUB shar

IF glupo = 1 THEN colora(shag) = 14: coob$ = " Одна ошибка ": GOSUB shar

IF glupo = 2 THEN colora(shag) = 2: coob$ = " Две ошибки! ": GOSUB shar

IF glupo = 3 THEN colora(shag) = 9: coob$ = " Три ошибки! ": GOSUB shar

IF glupo > 3 THEN colora(shag) = 15: coob$ = " Много ошибок!!! ": GOSUB shar

oshibka = oshibka + glupo

glupo = 0

COLOR colora(shag): LOCATE 20, 52: PRINT coob$: COLOR ccc

DO WHILE INKEY$ = "": LOOP

RETURN

napis:

LOCATE nx, ny: PRINT STRING$(mm, " ")

napis1:

k$ = ""

DO WHILE k$ = ""

LOCATE nx, ny: PRINT CHR$(95)

k$ = INKEY$

IF k$ = CHR$(0) + CHR$(59) THEN GOSUB reklama

LOOP

k = ASC(k$)

IF k = 13 AND m <> 0 THEN LOCATE nx, ny: PRINT " ": RETURN

IF k = 27 THEN GOSUB vihod

IF k = 8 AND m <> 0 THEN m = m - 1: m$ = LEFT$(m$, m): LOCATE nx, ny: ny = ny - 1: PRINT " ": GOTO napis1

IF INSTR(1, l$, k$) = 0 OR m = mm THEN GOTO napis1

m = m + 1:

m$ = m$ + k$: LOCATE nx, ny: PRINT k$: ny = ny + 1

GOTO napis1

vihod:

vih$ = ""

SCREEN 9, , 1, 1

CLS

LOCATE 10, 10

PRINT "Выйти из программы - <Esc>"

DO WHILE vih$ = ""

vih$ = INKEY$

IF vih$ = CHR$(27) THEN CLS : PRINT #3, "Выход из программы по желанию пользователя - "; TIME$: PRINT #3, : CLOSE #3: GOTO alis

LOOP

SCREEN 9, , 0, 0

RETURN

alis:

CLS

LOCATE 10, 30: PRINT "GOOD BYE !!!"

DO WHILE INKEY$ = "": LOOP

FOR i = 1 TO 120

LINE (i + 200, 140)-(i + 240, 120), 0

SOUND i * 3 + 1100, .05

FOR j = 1 TO speed: NEXT j

NEXT i

SYSTEM

slov:

COLOR 15

IF p < 10 THEN slovo$(1) = " Перемещай стрелку по ": slovo$(2) = " координатной плоскости ": slovo$(3) = "пользуясь клавишами " + CHR$(27) + CHR$(24) + CHR$(25) + "->": slovo$(4) = " Клавишей <ПРОБЕЛ> укажи "

IF p = 1 THEN slovo$(5) = " начало вектора AB "

IF p = 2 THEN slovo$(5) = " начало вектора CD "

IF p = 3 THEN slovo$(5) = " конец вектора AB "

IF p = 4 THEN slovo$(5) = " конец вектора CD "

IF p = 5 THEN slovo$(5) = " начало вектора m "

IF p = 6 THEN slovo$(5) = " конец вектора m "

IF p > 10 THEN slovo$(1) = " Введи с клавиатуры ": slovo$(3) = " и нажми <Enter> ": slovo$(4) = " если ошибся ": slovo$(5) = " нажми <== "

IF p = 11 THEN slovo$(2) = " координату x вектора AB "

IF p = 12 THEN slovo$(2) = " координату y вектора AB "

IF p = 13 THEN slovo$(2) = " координату x вектора CD "

IF p = 14 THEN slovo$(2) = " координату y вектора CD "

IF p = 15 THEN slovo$(2) = " координату x вектора m "

IF p = 16 THEN slovo$(2) = " координату y вектора m "

IF p = 20 THEN FOR cl = 1 TO 5: slovo$(cl) = " ": NEXT cl

LINE (403, 235)-(626, 309), 15, B

LINE (403, 235)-(625, 308), 7, B

PAINT (450, 240), 0, 7

FOR lo = 18 TO 22

LOCATE lo, 52: PRINT slovo$(lo - 17)

NEXT lo

LOCATE 6, 52: PRINT "<F1>-Помощь <Esc>-Выход"

LINE (403, 65)-(626, 89), 15, B

LINE (403, 65)-(625, 88), 7, B

COLOR ccc

RETURN

zapusk:

zapusk$(1) = " СЛОЖЕНИЕ ВЕКТОРОВ "

zapusk$(2) = " "

zapusk$(3) = " Тебе предстоит: "

zapusk$(4) = " выполнить 10 заданий "

zapusk$(5) = " "

zapusk$(6) = " В каждом задании нужно: "

zapusk$(7) = "1 - построить на "

zapusk$(8) = " координатной плоскости "

zapusk$(9) = " два вектора, указав "

zapusk$(10) = " их начало и конец "

zapusk$(11) = "2 - ввести их координаты "

zapusk$(12) = "3 - сложить построенные "

zapusk$(13) = " векторы и ввести "

zapusk$(14) = " координаты вектора суммы"

zapusk$(15) = "4 - построить вектор суммы"

zapusk$(16) = " указав начало вектора "

zapusk$(17) = " в произвольной точке "

zapusk$(18) = " "

FOR ii = 1 TO 26

FOR ki = speed TO speed * 2: BEEP: NEXT ki

FOR ji = 1 TO 18

LOCATE ji + 4, 51 + ii

PRINT MID$(zapusk$(ji), ii, 1)

NEXT ji

NEXT ii

DO WHILE INKEY$ = "": LOOP

FOR ii = 26 TO 1 STEP -1

FOR ki = speed TO speed * 2: BEEP: NEXT ki

FOR ji = 1 TO 18

LOCATE ji + 4, 51 + ii

PRINT " "

NEXT ji

NEXT ii

RETURN

glupo:

glupo = glupo + 1

FOR clor = 15 TO 0 STEP -1

PLAY "n60l20"

COLOR clor

LOCATE 16, 53: PRINT "ОШИБКА! ПОВТОРИТЕ ВВОД"

NEXT clor

COLOR ccc

RETURN

Приложение №3

Файл - vector2.bas

REM РАЗНОСТЬ ВЕКТОРОВ

'Константы

speed = 800 'Скорость

FILEHLP$ = "vector.hlp"

filerez$ = "vector.rez"

oshibka = 0 'Общее количество ошибок

k = 10 'Длина пера вектора

k1 = 3 'Ширина пера вектора

radius = 2 'Радиус начала вектора

zakr = 1 'Закраска начала вектора

zakrstr = 1 'Закраска стрелки вектора

c = 12 'Цвет стрелки - курсора

curx = 0: cury = 0 'Установка начальниых координат положения стрелки

DIM colora(10)