Division aritmetica de numeros enteros
Publicado por lrcvs (3 intervenciones) el 09/01/2010 22:45:06
'Program arithmetic division with integers numbers
'lrcvs
'09 Jan 2010
Dim a, b, c, v, t, d as string
Dim la, r,s as integer
Cls
a = "12345678956353565"
b = "3698"
la = Len (a)
c = String$(la,"0")
For r = 1 To la
For s = 0 To 9
Mid$(c,r) = Ltrim$(Str$(s))
v = Ltrim(Str$(Val (c) * Val (b)))
If Val(v) = Val(a) Then Print v: Exit For
If Val(a) > Val(v) Then Mid$(c,r) = Ltrim$(Str$(s))
If Val(a) < Val(v) Then Mid$(c,r) = Ltrim$(Str$(s-1)): Exit For
Next s
Next r
t = Ltrim$(Str$(Val(a)-(Val(c)*Val(b))))
d = Ltrim$(Str$(Val(t)/Val(b)))
Print "Programa = ";ltrim$(Str$(Val(c)))+Right$(d,Len(d)-1)
Print
print "Resto division = ";t
Print
print "Ordenador = ";val (a) / Val (b)
Sleep
End
'lrcvs
'09 Jan 2010
Dim a, b, c, v, t, d as string
Dim la, r,s as integer
Cls
a = "12345678956353565"
b = "3698"
la = Len (a)
c = String$(la,"0")
For r = 1 To la
For s = 0 To 9
Mid$(c,r) = Ltrim$(Str$(s))
v = Ltrim(Str$(Val (c) * Val (b)))
If Val(v) = Val(a) Then Print v: Exit For
If Val(a) > Val(v) Then Mid$(c,r) = Ltrim$(Str$(s))
If Val(a) < Val(v) Then Mid$(c,r) = Ltrim$(Str$(s-1)): Exit For
Next s
Next r
t = Ltrim$(Str$(Val(a)-(Val(c)*Val(b))))
d = Ltrim$(Str$(Val(t)/Val(b)))
Print "Programa = ";ltrim$(Str$(Val(c)))+Right$(d,Len(d)-1)
print "Resto division = ";t
print "Ordenador = ";val (a) / Val (b)
Sleep
End
Valora esta pregunta
0