Accueil     Soft. MacOSX     Soft. MacOS/PC     PHP     Python     ROMS GBA     TP d'info     DBZ-GT     Martingales     Galeries     Liens     @  

Exercice 2

program ex2;
type
ds = record
n: integer;
t: array[0..30] of real;
end;

var
i, k, n: integer;
x, res: real;
tab: ds;

function rand (minimum, maximum: integer): integer;
begin
rand := minimum + Abs(Random) mod (maximum - minimum + 1);
end;
{ Fin de la fonction 'rand' }

function rand2 (minimum, maximum: integer): real;
begin
rand2 := minimum + Abs(Random) mod (maximum - minimum + 1);
end;
{ Fin de la fonction 'rand2' }

function puiss (x: real; n: integer): real;
{ puissance }
var
i: integer;
val: real;
begin
val := x;
for i := 1 to n do
val := val * x;
puiss := val;
end;
{ Fin de la fonction 'puiss' }


begin
{ Debut du corps du programme }
writeln('Ex 2 par http://www.Software-DS.com');
writeln;

tab.n := rand(2, 30);

for i := 0 to tab.n do
tab.t[i] := rand2(0, 10);

write('P(x)=');

for i := 0 to tab.n do
{ Affichage du polynome }
begin
if i = 0 then
write(tab.t[i] : 0)
else if i = 1 then
write(tab.t[i] : 0, 'x')
else
write(tab.t[i] : 0, 'x^', i : 0);
if i <> tab.n then
write('+');
end;

writeln;
writeln;
x := rand2(1, 500);
write('P(', x : 0 : 5, ')= ');
for i := 0 to tab.n do
begin
if i = 0 then
res := tab.t[i]
else if i = 1 then
res := res + (tab.t[i] * x)
else
res := res + (tab.t[i] * puiss(x, i))
end;
writeln(res : 0 : 5);

writeln;
writeln('©2001 All Rights Reserved to www.Software-DS.com');
{ ©2001 All Rights Reserved to http://www.Software-DS.com 09/10/01 }
end.





Haut de la page - Page précédente - Page générée en 0.00170 sec.
Recherche personnalisée
 

1843944 visiteurs.   ©2001-2023 All Rights Reserved to Software-DS.com
Made with a mac  
Confidentialité