Skip to content

Instantly share code, notes, and snippets.

@Ishibasystems
Created July 4, 2016 16:11
Show Gist options
  • Save Ishibasystems/3a8dd975e6b36eaeb59e48993e73c8dc to your computer and use it in GitHub Desktop.
Save Ishibasystems/3a8dd975e6b36eaeb59e48993e73c8dc to your computer and use it in GitHub Desktop.
screen ,385,140
*START
CLS 0
PRINT "aX^2+bX+c=0の形まで解く"
title "2次方程式計算機"
POS 0,18
print"aは?"
POS 0,42
print"bは?"
POS 0,66
print"cは?"
POS 38,18
a=1
INPUT a,,,9
POS 38,42
INPUT b,,,9
POS 38,66
INPUT c,,,9
POS 0,90
BUTTON"計算",*NM
BUTTON"終了",*sa
POS 129,22
stop
*NM
CLS 0
PRINT "aX^2+bX+c=0の形まで解く"
title "2次方程式計算機"
POS 0,18
print"aは?"
POS 0,42
print"bは?"
POS 0,66
print"cは?"
POS 38,18
INPUT a,,,9
POS 38,42
INPUT b,,,9
POS 38,66
INPUT c,,,9
POS 0,90
BUTTON"計算",*NM
BUTTON"終了",*sa
POS 129,22
Y=INT(ABSF(B*B-4*A*C))
F=SQRT(Y)
P=INT(F)
J=-B/(2*A)
H=int(J)
T=F/(2*A)
K=INT(T)
print ""+A+"X^2+"+B+"X+"+C+"=0"
_y=INT(B*B-4*A*C)
if _y<0 : kkkkk++
if Y>0 : goto *AE
IF Y=0 : goto *AQ
*AE
print"複素根 "
IF F=P : goto *AG
if J=H : goto *AZ
if kkkkk!0 {
if b=0 {
mes "X=±(√"+Y+"i)÷"+(2*A)+""
}else{
mes "X="+(-B)+"/"+(2*A)+"±(√"+Y+"i)÷"+(2*A)+""
}
}else{
if b=0 {
mes "X=±(√"+Y+")÷"+(2*A)+""
}else{
mes "X="+(-B)+"/"+(2*A)+"±(√"+Y+")÷"+(2*A)+""
}
}
goto *AR
*AZ
if kkkkk!0 {
if j=0 {
mes "X=±(√"+Y+"i)÷"+(2*A)+""
}else{
mes "X="+J+"±(√"+Y+"i)÷"+(2*A)+""
}
}else{
if j=0 {
mes "X=±(√"+Y+")÷"+(2*A)+""
}else{
mes "X="+J+"±(√"+Y+")÷"+(2*A)+""
}
}
goto *AR
*AQ
mes "重解の解 "
mes "X="+(-B/(2*A))+""
GOTO *AR
*AP
if kkkkk!0 {
if b=0 {
mes "X=±(√"+(-Y)+"i)÷"+(2*A)+""
}else{
mes "X="+(-B)/(2*A)+"±(√"+(-Y)+"i)÷"+(2*A)+""
}
}else{
if b=0 {
mes "X=±(√"+(-Y)+")÷"+(2*A)+""
}else{
mes "X="+(-B)/(2*A)+"±(√"+(-Y)+")÷"+(2*A)+""
}
}
goto *AR
*AG
IF T=K : GOTO *AH
*AF
if kkkkk!0 {
if b=0 {
mes "X=±"+P+"i÷"+(2*A)+""
}else{
mes "X="+(-B)+"/"+(2*A)+"±"+P+"i÷"+(2*A)+""
}
}else{
if b=0 {
mes "X=±"+P+"÷"+(2*A)+""
}else{
mes "X="+(-B)+"/"+(2*A)+"±"+P+"÷"+(2*A)+""
}
}
GOTO *AR
*AH
if kkkkk!0 {
if b=0 {
mes "X=±"+P/(2*A)+"i"
}else{
mes "X="+(-B)+"/"+(2*A)+"±"+P/(2*A)+"i"
}
}else{
if b=0 {
mes "X=±"+P/(2*A)+""
}else{
mes "X="+(-B)+"/"+(2*A)+"±"+P/(2*A)+""
}
}
*AR
mes "ここからは自分で計算してください"
kkkkk=0
stop
*sa
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment