## Для школы

MARK99
Posts: 292
Joined: Tue Feb 03, 2015 2:33 pm
My devices: Ipad 4 , iphone 5
Flag:
Contact:

### Для школы

Это программа считает энергию атомов периодической таблицы , и их изотопов . Она мне очень помогла в 9 классе , мой учитель заставил весь класс считать внутреннюю энергию изотопов , на калькуляторе возится с такими числами сложно , поэтому я сделал данную программу как для iPad ,так и для iPhone.
(Скоро сделаю её без участия кнопок -для более быстрой работы)

Code: Select all

``````GRAPHICS
SET ORIENTATION P
i\$=0
IF p=2 OR p=4 THEN
IF p=2 THEN
SET ORIENTATION LEFT
END IF
IF p=4 THEN
SET ORIENTATION RIGHT
END IF
ELSE
SET ORIENTATION RIGHT
END IF
END IF
SET ORIENTATION P
i\$=0
IF p=2 OR p=4 THEN
IF p=2 THEN
SET ORIENTATION LEFT
END IF
IF p=4 THEN
SET ORIENTATION RIGHT
END IF
ELSE
SET ORIENTATION RIGHT
END IF
ENDIF
a1=SCREEN_WIDTH() 'ширина экрана
a2=SCREEN_HEIGHT() 'высота экрана
IF a2<a1 THEN
a3=a2
END IF
IF a1<a2 THEN
a3=a1
END IF
OPTION BASE 1

DIM ii\$(81)
DATA "H","He","Li","Be","B","C","N","O","F","Ne","Na","Mg","Al","Si","P","S","Cl","Ar","K","Ca","Sc","Ti","V","Cr","Mn","Fe","Co","Ni","Cu","Zn","Ga","Ge","As","Se","Br","Kr","Rb","Sr","Y","Zr","Nb","Mo","Tc","Ru","Rh","Pb","Ag","Cd","In","Sn","Sb","Te","I","Xe","Cs","Ba","La","Hf","Ta","W","Re","Os","Ir","Pt","Au","Hg","Ti","Pb","Bi","Po","At","Rn","Fr","Ra","Ac","Rf","Db","Sg","Bh","Hs","Mt"
FOR i=1 TO 81
NEXT i
mp=1.00728
mn=1.00867
me=0.00055
c2=931.5
a4=a1-a3
core=a3/10
cof=core
corx=a4
END IF
IF DEVICE_TYPE\$ ()="iPhone" THEN
corx=0
END IF
cory=0
i=0
FOR k1=1 TO 10
STR+=1
FOR k2=1 TO 10
PAUSE 0.1
i+=1
IF i=81 THEN ! k2=10 ! ENDIF
IF STR=1 THEN
BUTTON i TEXT ii\$(i) AT corx+core*6,cory SIZE cof,cof
corx+=core
IF i=2 THEN
k2=10
ENDIF
END IF

IF STR=4 OR STR=6 OR STR=8 OR STR=10  THEN

BUTTON i TEXT ii\$(i) AT corx,cory SIZE cof,cof
corx+=core
END IF

IF STR=2 OR STR=3 OR STR=5 OR STR=7 OR STR=9 THEN
BUTTON i TEXT ii\$(i) AT corx,cory SIZE cof,cof
corx+=core
IF i=10 OR i=18 OR i=54 OR i=36 OR i=72 THEN
k2=10
END IF
END IF
BUTTON "star" TEXT "создать" AT 0,0 SIZE 0,cof
END IF
IF DEVICE_TYPE\$ ()="iPhone" THEN
BUTTON "star" TEXT "создать" AT 0,a3 SIZE 0,cof
END IF

NEXT k2
corx=a4
END IF
IF DEVICE_TYPE\$ ()="iPhone" THEN
corx=0
END IF
cory+=core
NEXT k1
DRAW COLOR 1,1,1

LOOP:
IF BUTTON_PRESSED ("star")=1 THEN
BUTTON "star" HIDE
FOR i=1 TO 81
i\$=i
BUTTON i\$ HIDE
NEXT i
FILL COLOR 0,0,0
FILL RECT cof*2,0 TO cof*8, 55
TEXT

INPUT "электроны": elek
INPUT "нуклоны": izot
INPUT "масса": mass
GRAPHICS

BUTTON "star" SHOW
FOR i=1 TO 81
i\$=i
BUTTON i\$ SHOW
NEXT i
DRAW TEXT "(" & (elek) & "*" & mp & "+" & (izot-elek) & "*" & mn & "-" & (mass) & ")*" & c2 AT cof*2,0
DRAW TEXT "E= " & (elek*mp+(izot-elek)*mn-(mass) )*c2 AT cof*2,20
DRAW TEXT "Eу= " & ((elek*mp+(izot-elek)*mn-(mass) )*c2)/izot AT cof*2, 40
END IF
IF DEVICE_TYPE\$ ()="iPhone" THEN
DRAW TEXT "(" & (elek) & "*" & mp & "+" & (izot-elekb) & "*" & mn AT 0,0
DRAW TEXT  "-" & (mass) & ")*" & c2 AT 0,20
DRAW TEXT "E= " & (elek*mp+(izot-elek)*mn-mass)*c2 AT 0,40
DRAW TEXT "Eу= " & ((elek*mp+(izot-elek)*mn-mass)*c2)/izot AT 0, 60
DO
GET TOUCH 0 AS x,y
UNTIL x>3
FILL RECT 0,0 TO a3,a3
BUTTON "star" SHOW
FOR i=1 TO 81
i\$=i
BUTTON i\$ SHOW
NEXT i
END IF
ENDIF

FOR i=1 TO 81
nomer=i
i\$=i
IF BUTTON_PRESSED (i\$)=1 THEN
FILL COLOR 0,0,0
FILL RECT 0,0 TO a1,a2
GOSUB tabl
ENDIF
NEXT i
GOTO LOOP
tabl:
FOR i=1 TO 81
i\$=i
BUTTON i\$ HIDE
NEXT i
BUTTON "star" HIDE
BUTTON "ext" TEXT "назад"  AT a1-cof,0 SIZE cof,cof
DO
'r'

''

dat_base
DEF dat_base

mp=1.00728
mn=1.00867
me=0.00055
c2=931.5
RESTORE
DATA 1, 1.00794, 2, 4.002602, 3, 6.941, 4, 9.91216, 5, 10.811,6,12.11,7,14.0067,8,15.9994,9,18.998403,10,20.179,11,22.98977,12,24.30,13,26.98154,14,28.0855,15,30.97376,16,32.066,17,35.453,18,39.948,19,39.0983,20,40.078,21,44.95591,22,47.88,23,50.9415,24,51.9961,25,54.9380,26,55.847,27,58.9332,28,58.69,63,63.546,30,65.39,31,69.723,32,72.59,33,74.9216,34,78.96,35,79.904,36,83.8,37,85.4678,38,87.62,39,88.9059,40,91.224,41,92.9064,42,95.94,43,98,44,101.07,45,102.9055,46,106.42,47,107.8682,48,112.41,49,114.82,50,118.71,51,121.75,52,127.6,53,126.9045,54,131.29,55,132.9054,56,137.33,57,138.9055,72,178.49,73,180.9479,74,183.85,75,186.207,76,190.2,77,192.22,78,195.08,79,196.9665,80,200.59,81,204.383,82,207.2,83,208.9804,84,209,85,210,86,222,87,223,88,226,89,227,104,261,105,262,106,263,107,262,108,265,109,266
FOR nomer=1 TO 162
IF FRACT (aa2)>.88 THEN
aa3=INTEG (aa2)+1
ELSE
aa3=INTEG (aa2)
END IF
IF nomer=.nomer THEN
DRAW TEXT "Нуклоны:"&aa3 AT 0,0
DRAW TEXT "Электроны:"&aa1 AT 0,20
DRAW TEXT "масса:"&aa2 AT 0,40
DRAW TEXT "E="&"("&aa1&"*"&mp&"+"&(aa3-aa1)&"*"&mn&"-"&(aa2-aa1*me)&")*"&c2 AT 0,60
DRAW TEXT "E="&(aa1*mp+(aa3-aa1)*mn-(aa2-aa1*me))*c2 AT 0,80
DRAW TEXT "Ey="&((aa1*mp+(aa3-aa1)*mn-(aa2-aa1*me))*c2)/aa3 AT 0,100
ENDIF
IF DEVICE_TYPE\$ ()="iPhone" THEN
DRAW TEXT "Нуклоны:"&aa3 AT 0,0
DRAW TEXT "Электроны:"&aa1 AT 0,20
DRAW TEXT "масса:"&aa2 AT 0,40

DRAW TEXT "E="&"("&aa1&"*"&mp&"+"&(aa3-aa1)&"*"&mn AT 0,60
draw text "-"&(aa2-aa1*me)&")*"&c2 at 0,80
DRAW TEXT "E="&(aa1*mp+(aa3-aa1)*mn-(aa2-aa1*me))*c2 AT 0,100
DRAW TEXT "Ey="&((aa1*mp+(aa3-aa1)*mn-(aa2-aa1*me))*c2)/aa3 AT 0,140
END IF
RETURN
ENDIF
NEXT nomer
END DEF
IF BUTTON_PRESSED ("ext")=1 THEN
ex=1
END IF

UNTIL ex=1
FILL COLOR 0,0,0
FILL RECT 0,0 TO a1,a2
BUTTON "ext" DELETE
FOR i=1 TO 81
i\$=i
BUTTON "star" SHOW
BUTTON i\$ SHOW
NEXT i
ex=0
RETURN
``````

Фант
Posts: 1363
Joined: Sat Nov 30, 2013 10:01 am
My devices: iPad 4 (iOS 9.3), iMac (MAC OS 11.03)
Location: Россия,Санкт-Петербург
Flag:
Contact:

### Re: Для школы

код не работает. где то endif потерялся

MARK99
Posts: 292
Joined: Tue Feb 03, 2015 2:33 pm
My devices: Ipad 4 , iphone 5
Flag:
Contact:

### Re: Для школы

Фант wrote:код не работает. где то endif потерялся
Попробуйте здесь , но умнея всё работает .

https://www.dropbox.com/s/hjp1ye7y8o5up ... 0.txt?dl=0

MARK99
Posts: 292
Joined: Tue Feb 03, 2015 2:33 pm
My devices: Ipad 4 , iphone 5
Flag:
Contact:

### Re: Для школы

Фант wrote:код не работает. где то endif потерялся
Фант ,спасибо , я буду блогадарин, если вы взглянете на структуру кода и подправите меня где нибудь .

Фант
Posts: 1363
Joined: Sat Nov 30, 2013 10:01 am
My devices: iPad 4 (iOS 9.3), iMac (MAC OS 11.03)
Location: Россия,Санкт-Петербург
Flag:
Contact:

### Re: Для школы

выдает синтактическую ошибку : IF STR=4 OR STR=6 OR STR=8 OR STR=10 THEN

MARK99
Posts: 292
Joined: Tue Feb 03, 2015 2:33 pm
My devices: Ipad 4 , iphone 5
Flag:
Contact:

### Re: Для школы

Фант wrote:выдает синтактическую ошибку : IF STR=4 OR STR=6 OR STR=8 OR STR=10 THEN
Не понимаю ,где ошибка -на iPhone ,iPad все работает,
Попробуете предыдущую версию программы :

Code: Select all

``````graphics
SET ORIENTATION P
i\$=0
if p=2 or p=4 then
if p=2 then
SET ORIENTATION LEFT
end if
if p=4 then
SET ORIENTATION RIGHT
end if
else
SET ORIENTATION right
end if
end if

i\$=0
if p=2 or p=4 then
if p=2 then
SET ORIENTATION LEFT
end if
if p=4 then
SET ORIENTATION RIGHT
end if
else
SET ORIENTATION right
end if
endif
a1=screen_width() 'ширина экрана
a2=screen_height() 'высота экрана
if a2<a1 then
a3=a2
end if
if a1<a2 then
a3=a1
end if
OPTION BASE 1

dim ii\$(81)
data "H","He","Li","Be","B","C","N","O","F","Ne","Na","Mg","Al","Si","P","S","Cl","Ar","K","Ca","Sc","Ti","V","Cr","Mn","Fe","Co","Ni","Cu","Zn","Ga","Ge","As","Se","Br","Kr","Rb","Sr","Y","Zr","Nb","Mo","Tc","Ru","Rh","Pb","Ag","Cd","In","Sn","Sb","Te","I","Xe","Cs","Ba","La","Hf","Ta","W","Re","Os","Ir","Pt","Au","Hg","Ti","Pb","Bi","Po","At","Rn","Fr","Ra","Ac","Rf","Db","Sg","Bh","Hs","Mt"
for i=1 to 81
next i
mp=1.00728
mn=1.00867
me=0.00055
c2=931.5
a4=a1-a3
core=a3/10
cof=core
corx=a4
end if
if DEVICE_TYPE\$ ()="iPhone" then
corx=0
end if
cory=0
i=0
for k1=1 to 10
str+=1
for k2=1 to 10
i+=1
if i=81 then ! k2=10 ! endif
if str=1 then
BUTTON i text ii\$(i) AT corx+core*6,cory SIZE cof,cof
corx+=core
if i=2 then
k2=10
endif
end if

if str=4 or str=6 or str=8 or str=10  then

BUTTON i text ii\$(i) AT corx,cory SIZE cof,cof
corx+=core
end if

if str=2 or str=3 or str=5 or str=7 or str=9 then
BUTTON i text ii\$(i) AT corx,cory SIZE cof,cof
corx+=core
if i=10 or i=18 or i=54 or i=36 or i=72 then
k2=10
end if
end if
BUTTON "star" TEXT "создать" AT 0,0 SIZE 0,cof
end if
if DEVICE_TYPE\$ ()="iPhone" then
BUTTON "star" TEXT "создать" AT 0,a3 SIZE 0,cof
end if

next k2
corx=a4
end if
if DEVICE_TYPE\$ ()="iPhone" then
corx=0
end if
cory+=core
next k1
draw color 1,1,1

loop:
if BUTTON_PRESSED ("star")=1 then
BUTTON "star" hide
for i=1 to 81
i\$=i
BUTTON i\$ hide
next i
fill color 0,0,0
fill rect cof*2,0 to cof*8, 55
text

INPUT "электроны": elek
INPUT "нуклоны": izot
INPUT "масса": mass
graphics

BUTTON "star" show
for i=1 to 81
i\$=i
BUTTON i\$ show
next i
draw text "(" & (elek) & "*" & mp & "+" & (izot-elek) & "*" & mn & "-" & (mass) & ")*" & c2 at cof*2,0
draw text "E= " & (elek*mp+(izot-elek)*mn-(mass) )*c2 at cof*2,20
draw text "Eу= " & ((elek*mp+(izot-elek)*mn-(mass) )*c2)/izot at cof*2, 40
end if
if DEVICE_TYPE\$ ()="iPhone" then
draw text "(" & (elek) & "*" & mp & "+" & (izot-elekb) & "*" & mn at 0,0
draw text  "-" & (mass) & ")*" & c2 at 0,20
draw text "E= " & (elek*mp+(izot-elek)*mn-mass)*c2 at 0,40
draw text "Eу= " & ((elek*mp+(izot-elek)*mn-mass)*c2)/izot at 0, 60
do
get touch 0 as x,y
until x>3
fill rect 0,0 to a3,a3
BUTTON "star" show
for i=1 to 81
i\$=i
BUTTON i\$ show
next i
end if
endif

for i=1 to 81
nomer=i
i\$=i
if BUTTON_PRESSED (i\$)=1 then
fill color 0,0,0
fill rect 0,0 to a1,a2
gosub tabl
endif
next i
goto loop
tabl:
for i=1 to 81
i\$=i
BUTTON i\$ hide
next i
BUTTON "star" hide
BUTTON "ext" text "назад"  AT a1-cof,0 SIZE cof,cof
do
'r'

''

dat_base
Def dat_base

mp=1.00728
mn=1.00867
me=0.00055
c2=931.5
Restore
Data 1, 1, 1.00794, 4, 2, 4.002602, 6, 3, 6.941, 9, 4, 9.91216, 10, 5, 10.811, 12, 6,12.11,14,7,14.0067,15,8,15.9994,18,9,18.998403,20,10,20.179,22,11,22.98977,24,12,24.30,26,13,26.98154,28,14,28.0855,30,15,30.97376,32,16,32.066,35,17,35.453,39,18,39.948,39,19,39.0983,40,20,40.078,44,21,44.95591,47,22,47.88,50,23,50.9415,51,24,51.9961,54,25,54.9380,55,26,55.847,58,27,58.9332,58,28,58.69,29,63,63.546,65,30,65.39,69,31,69.723,72,32,72.59,74,33,74.9216,78,34,78.96,79,35,79.904,83,36,83.8,85,37,85.4678,87,38,87.62,88,39,88.9059,91,40,91.224,92,41,92.9064,95,42,95.94,98,43,98,101,44,101.07,102,45,102.9055,106,46,106.42,107,47,107.8682,112,48,112.41,114,49,114.82,118,50,118.71,121,51,121.75,127,52,127.6,126,53,126.9045,131,54,131.29,132,55,132.9054,137,56,137.33,138,57,138.9055,178,72,178.49,180,73,180.9479,183,74,183.85,186,75,186.207,190,76,190.2,192,77,192.22,195,78,195.08,196,79,196.9665,200,80,200.59,204,81,204.383,207,82,207.2,208,83,208.9804,209,84,209,210,85,210,222,86,222,223,87,223,226,88,226,227,89,227,261,104,261,262,105,262,263,106,263,262,107,262,265,108,265,266,109,266
For nomer=1 to 243
If nomer=.nomer then
draw text "Нуклоны:"&aa1 at 0,0
draw text "Электроны:"&aa2 at 0,20
draw text "масса:"&aa3 at 0,40
draw text "E="&"("&aa2&"*"&mp&"+"&(aa1-aa2)&"*"&mn&"-"&(aa3-aa1*me)&")*"&c2 at 0,60
draw text "E="&(aa2*mp+(aa1-aa1)*mn-(aa3-aa1*me))*c2 at 0,80
draw text "Ey="&((aa2*mp+(aa1-aa2)*mn-(aa3-aa1*me))*c2)/aa1 at 0,100
endif
if DEVICE_TYPE\$ ()="iPhone" then
draw text "Нуклоны:"&aa1 at 0,0
draw text "Электроны:"&aa2 at 0,20
draw text "масса:"&aa3 at 0,40
draw text "E="&"("&aa2&"*"&mp&"+"&(aa1-aa2)&"*"&mn at 0,60
draw text "-"&(aa3-aa1*me)&")*"&c2 at 0,80
draw text "E="&(aa2*mp+(aa1-aa2)*mn-(aa3-aa1*me))*c2 at 0,100
draw text "Ey="&((aa2*mp+(aa1-aa2)*mn-(aa3-aa1*me))*c2)/aa1 at 0,120
end if
Return
Endif
Next nomer
End def
if BUTTON_PRESSED ("ext")=1 then
ex=1
end if

until ex=1
fill color 0,0,0
fill rect 0,0 to a1,a2
BUTTON "ext" DELETE
for i=1 to 81
i\$=i
BUTTON "star" show
BUTTON i\$ show
next i
ex=0
return
``````

Фант
Posts: 1363
Joined: Sat Nov 30, 2013 10:01 am
My devices: iPad 4 (iOS 9.3), iMac (MAC OS 11.03)
Location: Россия,Санкт-Петербург
Flag:
Contact:

### Re: Для школы

Эта версия работает)

Фант
Posts: 1363
Joined: Sat Nov 30, 2013 10:01 am
My devices: iPad 4 (iOS 9.3), iMac (MAC OS 11.03)
Location: Россия,Санкт-Петербург
Flag:
Contact:

### Re: Для школы

А у тебя ошибку не выдает?

MARK99
Posts: 292
Joined: Tue Feb 03, 2015 2:33 pm
My devices: Ipad 4 , iphone 5
Flag:
Contact:

### Re: Для школы

Фант wrote:А у тебя ошибку не выдает?
У меня не выдаёт .