1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
| Program ex1;
uses WinCrt;
Type
couple = Record
x,y:Integer
end;
element = Record
pgcd,ppcm,min,max,a,c:Integer;
p:LongInt;
end;
tab1=array [1..40] of couple;
tab2=array [1..40] of element;
var n,i:Integer; t:tab1; r:tab2; f:text; x,y:Integer;
Procedure saisir(var n:Integer);
Begin
Repeat
writeln('donner n');
readln(n);
until n in [1..40];
end;
Procedure rempliar( t:tab1 ;var r:tab2; n:integer);
var i:Integer;
Begin
for i:=1 to n Do
Repeat
writeln('tapez x');
readln(t[i].x);
writeln('tapez y');
readln(t[i].y);
until ((t[i].y > 0 ) and (t[i].y > 0 ) );
end;
Function fact(x:Integer):LongInt; var f:Integer;
Begin
f:=1;
for i:=1 to n Do
f:=f*i;
fact:=f;
end;
Function pgcd(x,y:integer):Integer;
Begin
end;
Function ppcm(x,y:Integer):integer;
Begin
end;
function min(x,y:Integer):integer;
Begin
end;
Function Max(x,y:Integer):integer;
Begin
End;
Function arrang(x,y:Integer):integer;
var a:Integer;
Begin
a:=1;
for i:=(y-x+1) to y Do
a:=a*1;
arrang:=a;
end;
Function combinaison(x,y:Integer):integer;
Begin
combinaison:=fact(y)div(fact(x)*fact(y)div fact(y-x));
end;
Function puissance(x:real;y:Integer):real;
var p:real;
Begin
p:=1;
for i:=1 to abs(y)Do
p:=p*x;
if y<0 then
p:=1/p;
puissance:=p;
End;
Procedure calculer(var t:tab1;r:tab2;n:Integer);
Begin
writeln('le calculer est ',pgcd(x,y));
writeln('le ppcm est = ' ,ppcm(x,y));
writeln('le minmum est = ',min(x,y));
writeln('lemaximum est = ' ,max(x,y));
writeln('larrangement est = ',arrang(x,y));
writeln('le combinaison est = ',combinaison(x,y));
writeln('le puissance est = ',puissance(x,y));
end;
Procedure tri(r:tab2;var t:tab1;n:Integer);
var p,aux,kes:Integer;
Begin
p:=0;
for i:=1 to (n-1) do
if r[i].pgcd > r[i+1].pgcd Then
p:=p+1;
aux:=r[i];
r[i]:=r[i+1];
r[i+1]:=aux;
kes:=t[i];
t[i]:=t[i+1];
t[i+1]:=kes;
end;
Procedure stock(var f:text;t:tab1;r:tab2;n:Integer);
Begin
for i:=1 to n Do
writeln(f,t[i].x,'|',t[i].y,'#',r[i].pgcd,'|',r[i].ppcm,'#',r[i].min ,'|',r[i].max,'#',r[i].a,'|',r[i].c,'|',r[i].p);
end;
Begin
assign(f,'ftnit.txt');
saisir(n);
rempliar(t,r,n);
calculer(t,r,n);
tri(t,r,n);
stock(f,t,r,n);
end. |
Partager