Escalomento sistema linear, adaptado Revista INPUT 1986,1987

 

'rem FREEBASIC, Escalomento sistema linear, adaptado Revista INPUT 1986,1987
'divertimentos matematicos, o problema da distribicao de selos para crianças

dim r as integer
dim c as integer
dim k as integer
dim j as integer
dim l as integer
dim jj as integer
dim kk as integer


input "digite o numero de linhas";r
c=r+1
dim a(r,c) as double
dim b(r,c) as double
dim ab(c) as string

for k=1 to c-1
input "nome das colunas";ab(k)
next k

for j=1 to r
print:print "valores para linha ";j
for k=1 to c
print "a(";j;",";k;") "
input a(j,k)
'print a(j,k);" ";
b(j,k)=a(j,k)
next k
next j

'rot1:
for l=1 to r
'rot11:

gosub rot2
gosub rot3



'rot31:
cls
for k=1 to c
locate 1, 8*k+2:print ab(k)
next k
'for j=1 to r
'for k=1 to c
'locate 2*j+1,8*k+40:print b(j,k)
'next k
'next j
'locate 4*j,1: print "respostas:-"
'for k=1 to r
'locate 4*j+10,k*20:print (a(k,c))
'locate 5*j+10,k*20:print (l)
'next k
'sleep
next l

for jj=1 to r
for kk=1 to c
locate 2*jj+1,8*kk+2:print using "#.##  ";a(jj,kk)
'locate 5,5:print 'm"
next kk
next jj
beep
'gosub rot1

'gosub rot31


rot2:
d=a(l,l)
for k=1 to c
a(l,k)=a(l,k)/d
next k
return

rot3:
for j=1 to c-1
if j=l then j=j+1
f=a(j,l)
for k=1 to c

a(j,k)=a(j,k)-(f*a(l,k))
next k
Next j
return

sleep

Abaixo, versão macro openoffice libreoffice BASIC

sub ooselos1

'Escalonamento, adaptado BASIC TK90X, MSX, Revista INPUT,NOVA CULTURAL, 1986,1987

dim r as integer
dim c as integer
dim k as integer
dim j as integer
dim l as integer
dim conta as integer
dim eq as integer
dim va as integer
dim d as double

inimp=4
inicol=1
conta=0


oDoc = ThisComponent
oPlanilha = oDoc.Sheets(12)

oCelula = oPlanilha.getCellByPosition(0,0)
oCelula.setString(" ENTRADA DE DADOS")

oCelula = oPlanilha.getCellByPosition(0,1)
oCelula.setString(" ENTRE O NUMERO DE EQUAÇOES = ")
oCelula = oPlanilha.getCellByPosition(4,1)
eq=oCelula.getString()

oCelula = oPlanilha.getCellByPosition(0,2)
oCelula.setString("ENTRE O NUMERO DE variaveis = ")
oCelula = oPlanilha.getCellByPosition(4,2)
va=oCelula.getString()


r=eq

'input "digite o numero de linhas";r
c=r+1
dim a(r+10,c+10) as double
dim b(r+10,c+10) as double

'Entrada de dados
oDoc = ThisComponent
oPlanilha = oDoc.Sheets(12)
'carrega matriz a(i,j) da Planilha1
For i = 1 To r
For j = 1 To c

oCelula = oPlanilha.getCellByPosition(inicol+j,inimp-1)
oCelula.setValue(i)

oCelula = oPlanilha.getCellByPosition(inicol,inimp+i)
oCelula.setValue(i)


oCelula = oPlanilha.getCellByPosition(inicol+j,inimp+i)
a(i,j)=oCelula.getString()
b(i,j)=a(i,j)

next j
next i
d=1



for l=1 to r


d=a(l,l)
for k=1 to c
a(l,k)=a(l,k)/d
next k
'return

'rot3:

for j=1 to c-1
if j=l then j=j+1
f=a(j,l)
for k=1 to c

a(j,k)=a(j,k)-(f*a(l,k))
next k
Next j


'return
next l



beep

'sleep
oDoc = ThisComponent
oPlanilha = oDoc.Sheets(11)
'carrega matriz a(i,j) da Planilha1
For i = 1 To r
For j = 1 To c

oCelula = oPlanilha.getCellByPosition(inicol+j,inimp-1)
oCelula.setValue(i)

oCelula = oPlanilha.getCellByPosition(inicol,inimp+i)
oCelula.setValue(i)


oCelula = oPlanilha.getCellByPosition(inicol+j,inimp+i)
oCelula.setValue(a(i,j))
'b(i,j)=a(i,j)

next j
next i

end sub

******************








Comentários