2
« en: Domingo 7 de Enero de 2007, 18:14 »
program EIX_activitat1;
{$APPTYPE CONSOLE}
uses
SysUtils;
type
T_poli = RECORD
grau: integer;
coef: ARRAY [0..15] of real;
end;
var
a,b,PoliGran,PoliPetit,s,m:T_poli;
k:integer;
procedure llegir_polinomi (VAR p:T_poli);
var i:integer;
begin
write('GRAU MAX POLINOMI: ');
readln(p.grau); writeln;
for i:=0 to p.grau do
begin
write('Indrodueix el coeficient per a grau [',i,']: ');
readln(p.coef);
end;
end;
procedure sumar_polinomi (VAR a,b,s:T_poli);
var i:integer;
begin
if a.grau>b.grau then
begin
PoliGran:= a;
PoliPetit:= b;
end
else
begin
PoliGran:= b;
PoliPetit:= a;
end;
for i:=0 to PoliGran.grau do
begin
s.coef := PoliGran.coef + PoliPetit.coef;
end;
writeln; writeln;
write('EL RESULTAT DE LA SUMA ES:'); writeln;
writeln;
for i:=0 to PoliGran.grau do
begin
writeln('GRAU [',i,']: ',s.coef:0:0,'');
end;
end;
procedure multiplicar_polinomi (VAR a,b,m:T_poli);
var i,j:integer;
begin
if a.grau>b.grau then
begin
PoliGran:= a;
PoliPetit:= b;
end
else
begin
PoliGran:= b;
PoliPetit:= a;
end;
m.coef[i+j]:=0;
for i:=0 to PoliPetit.grau do
for j:=0 to PoliGran.grau do
begin
m.coef[i+j]:=m.coef[i+j]+(PoliPetit.coef*PoliGran.coef[j]);
end;
for i:=0 to PoliGran.grau do
begin
writeln('GRAU [',i,']: ',m.coef:0:0,'');
end;
end;
var
opcio:integer;
begin
writeln;
writeln('OPERACIONS AMB POLINOMIS');
writeln;
writeln;
begin
repeat
writeln ('MENU:');
writeln ('Llegir polinomi');
writeln ('Sumar polinomi');
writeln ('mulitiplicar polinomi');
writeln ('sortir del programa');
readln (opcio);
case (opcio) of
1:writeln ('has escollit llegir poli');
2:writeln ('has escollit sumar poli');
3:writeln ('has escollit multiplicar poli');
0:writeln ('has escollit acabar');
else
writeln ('error');
end;
readln
until opcio = 0
readln;
end.
me da un error en readln; y en el end. final, alguna ayuda plz