Нам наш учитель вчера задал такую задачу...
Вводяться коэффиценты 2 многочленов и требуеться разделить их друг на друга
и вывести коэффиценты получившегося многочлена...
помогите составить кратчайший алгоритм...
program Vremya_09_03_07;
uses crt;
var k1,k2,k3:array[1..100] of real;
i,kol1,kol2,j,s1,s2:integer;
begin
clrscr;
repeat
write('Vvedite naivysshuu stepen` delimogo: ');
readln(kol1);
until (kol1 > 0) and (kol1 <= 100);
kol1 := kol1 + 1;
repeat
write('Vvedite naivysshuu stepen` delitelya: ');
readln(kol2);
until (kol2 >= 0) and (kol2 <= kol1);
kol2 := kol2 + 1;
writeln('Vvedite koeffichienty delimogo: ');
for i := 1 to kol1 do
read(k1[i]);
writeln('Vvedite koeffichienty delitelya: ');
for i := 1 to kol1 do
if i <= kol1-kol2 then k2[i] := 0 else read(k2[i]);
j := 0;
s1 := 0;
repeat
s2 := 1;
for i := 1 to kol1 do
if k2[i] <> 0 then break else s2 := s2 + 1;
s1 := s1 + 1;
if s2 >= s1 then
begin
j := j + 1;
k3[j] := k1[s1]/k2[s2];
for i := s1 to kol1 do
k1[i] := k1[i] - k2[s2+i-s1]*k3[j];
end;
until s2 < s1;
writeln('Koeffichienty poluchenogo mnogochlena: ');
for i := 1 to s1-1 do
write(k3[i]:4 :2,' ');
writeln;
writeln('Ostatok: ');
for i := s1 to kol1 do
write(k1[i]:4 :2,' ');
readkey;
end.
program Vremya_09_03_07;
uses crt;
var k1,k2,k3:array[1..100] of real;
i,kol1,kol2,j,s1,s2:integer;
begin
clrscr;
repeat
write('Vvedite naivysshuu stepen` delimogo: ');
readln(kol1);
until (kol1 > 0) and (kol1 <= 100);
kol1 := kol1 + 1;
repeat
write('Vvedite naivysshuu stepen` delitelya: ');
readln(kol2);
until (kol2 >= 0) and (kol2 <= kol1);
kol2 := kol2 + 1;
writeln('Vvedite koeffichienty delimogo: ');
for i := 1 to kol1 do
read(k1[i]);
writeln('Vvedite koeffichienty delitelya: ');
for i := 1 to kol1 do
if i <= kol1-kol2 then k2[i] := 0 else read(k2[i]);
j := 0;
s1 := 0;
repeat
s2 := 1;
for i := 1 to kol1 do
if k2[i] <> 0 then break else s2 := s2 + 1;
s1 := s1 + 1;
if s2 >= s1 then
begin
j := j + 1;
k3[j] := k1[s1]/k2[s2];
for i := s1 to kol1 do
k1[i] := k1[i] - k2[s2+i-s1]*k3[j];
end;
until s2 < s1;
writeln('Koeffichienty poluchenogo mnogochlena: ');
for i := 1 to s1-1 do
write(k3[i]2,' ');
writeln;
writeln('Ostatok: ');
for i := s1 to kol1 do
write(k1[i]2,' ');
readkey;
end.
var ar1,ar2,ar3:array[1..100] of real;
i,kol1,kol2,j,k,l:integer;
begin
write('Vvedite naivysshuyu stepen` delimogo: ');
readln(kol1);
inc(kol1);
write('Vvedite naivysshuyu stepen` delitelya: ');
readln(kol2);
inc(kol2);
writeln('Vvedite koeffichienty delimogo: ');
for i:=1 to kol1 do read(ar1);
writeln('Vvedite koeffichienty delitelya: ');
for i:=1 to kol1 do read(ar2[i]);
l:=kol1-kol2;
repeat
inc(k);
if l>=k then
begin
inc(j);
ar3[j]:=ar1[k]/ar2[l];
for i:=k to kol1 do ar1[i]:=ar1[i]-ar2[l+i-k]*ar3[j];
end;
until l<k;
writeln('Koeffichienty poluchenogo mnogochlena: ');
for i:=1 to k-1 do write(ar3[i],' ');
writeln;
writeln('Ostatok: ');
for i:=k to kol1 do write(ar1[i],' ');
end.
writeln('Vvedite koeffichienty delitelya: ');
for i:=1 to kol1 do read(ar2[i]);
ar3[j]:=ar1[k]/ar2[l];