Anonymous user
User:Xkrouhn: Difference between revisions
m
Rm header, don't want to count flase code examples (this one is duplicated on the task page)
(Don't mark your user page as a task) |
m (Rm header, don't want to count flase code examples (this one is duplicated on the task page)) |
||
(2 intermediate revisions by one other user not shown) | |||
Line 17:
==
<lang qbasic>
'
'LRCVS 11.06.11
Line 25:
declare sub puro (a$, b$())
declare sub mixto (a$, b$())
declare
dim as integer l, r, s, t, k, w1, i, m, x, ll, pp, ps, u, v, j
dim as string a, c, d, a2
dim y () as string
Line 36:
cls
input "Decimal number = ";a$
print
if instr(a$,".") = 0 then print "
cls
l = len(a$)
Line 87 ⟶ 88:
next r
print "
print
'print▼
ll = len(a$)
pp = instr(a$,".")
Line 96:
ps = instr(d$,b$(1))
if ps = 0 then
print "
print
call exacto (a$)
end if
if ps = 1 then
print "
print
call puro (a$, b$())
Line 107:
if ps > 1 then
print "
print
call mixto (a$, b$())
Line 117:
end
'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
sub exacto (a$)▼
sub exacto (a as string)
dim as integer b, c, d, g, may, j, k, l, r, s, u, v, w, f
dim as string z, h, g1
Line 123 ⟶ 124:
c = instr(a$,".")
d = b - c
▲z$ = "0"
g = int(val(a$))
h$ = right$(a$, b - c)
Line 130:
j = 10^d
k = val(h$)
for n = 9 to 1 step - 1
if j mod (1*(10^n)) = 0 and k mod (1*(10^n)) = 0 then j = j/(1*(10^n)) : k = k/(1*(10^n)) :
l = 1▼
for n = 1 to may▼
r = (j mod n)▼
s = (k mod n)▼
if r = 0 and s = 0 then l = n▼
next n
l = factor (j,k)
u = k/l
v = j/l
w = (g * v) + u
print w;"/";v ;" = " ;w/v
end sub
'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
sub puro (a as string, b() as string)
dim as integer b2, c, d, g, may, j, k, l,
dim as string z, h, g1, x, a3
z$ = b$(1)
lr = len (z$)
b2 = len (a$)
Line 156 ⟶ 154:
g = int (val(a$))
b2 = len(z$) + 1 + len(str$(g))
h$ = right$(
may = 0
x$ = ""
for n = 1 to lr
Line 167 ⟶ 165:
j = val(x$)
k = val(h$)
l = 1▼
for n = 9 to 1 step - 1
if j mod (1*(10^n)) = 0 and k mod (1*(10^n)) = 0 then j = j/(1*(10^n)) : k = k/(1*(10^n)) :
for n = 1 to may▼
next n
l = factor (j,k)
u = k/l
v = j/l
w = (g * v) + u
print w;"/";v ;" = ";w/v
print▼
print "Option >>> "
end sub
'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
sub mixto (a as string, b() as string)
dim as integer b3, c, d, g
dim as string z, h, g4, g7, x, y
Line 197 ⟶ 195:
b3 = (val(y$)*(9*(10^ly))) + ((1*(10^ly))* (val(z$)))
c = (9*(10^ly))*(1*(10^ly))
may = 0 ▼
j = b3
k = c
for n = 9 to 1 step - 1
if j mod (1*(10^n)) = 0 and k mod (1*(10^n)) = 0 then j = j/(1*(10^n)) : k = k/(1*(10^n))
next n
l = factor (b3,c)
▲u = k/l
if x5 <> 0 then print (x5*v)+ u;"/";u ;" = ";((x5*v)+ u)/u else print v;"/";u;" = "; v/u
print
print "Option >>> "
j = 0▼
call exacto (a$)
end sub
'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
function factor (j as integer, k as integer) as integer
dim as integer
▲print
if
▲e$ = str$(int(val(a$)))
▲if j mod (1*(10^n)) = 0 and k mod (1*(10^n)) = 0 then j = j/(1*(10^n)) : k = k/(1*(10^n)) : exit for
next n
next n
factor = l5
end function
end</lang>
|