простая задача, простая реализация
Procedure.l max(a.l,b.l)
If a>=b
ProcedureReturn a
Else
ProcedureReturn b
EndIf
EndProcedure
n1.s="1"
n2.s="1"
Debug n1
Debug n2
;addition
For g=1 To 12
a.s=""
l1.l=Len(n1)
l2.l=Len(n2)
dr.l=0;decimal rest
For i=1 To max(l1,l2)
If i<=l1
a1.l=Val(Mid(n1,i,1))
Else
a1=0
EndIf
If i<=l2
a2.l=Val(Mid(n2,i,1))
Else
a2=0
EndIf
re.l=dr+a1+a2
a=a+Str(re%10)
dr=Int(re/10)
Next i
If dr<>0
a=a+Str(dr)
EndIf
Debug ReverseString(a)
n1=n2
n2=a
Next g
; IDE Options = PureBasic 5.30 (Windows - x86)
; CursorPosition = 13
; FirstLine = 3
; Folding = -
; EnableUnicode
; EnableXP
If a>=b
ProcedureReturn a
Else
ProcedureReturn b
EndIf
EndProcedure
n1.s="1"
n2.s="1"
Debug n1
Debug n2
;addition
For g=1 To 12
a.s=""
l1.l=Len(n1)
l2.l=Len(n2)
dr.l=0;decimal rest
For i=1 To max(l1,l2)
If i<=l1
a1.l=Val(Mid(n1,i,1))
Else
a1=0
EndIf
If i<=l2
a2.l=Val(Mid(n2,i,1))
Else
a2=0
EndIf
re.l=dr+a1+a2
a=a+Str(re%10)
dr=Int(re/10)
Next i
If dr<>0
a=a+Str(dr)
EndIf
Debug ReverseString(a)
n1=n2
n2=a
Next g
; IDE Options = PureBasic 5.30 (Windows - x86)
; CursorPosition = 13
; FirstLine = 3
; Folding = -
; EnableUnicode
; EnableXP
Комментарии
Отправить комментарий