Sous-sections

2.2 Exemple: recherche PGCD(a,b)

2.2.1 analyse

2.2.2 algorithme PGCD


\begin{algor}[1]
\item [{definir}] a,b: entiers
\item [{tantque}] $a\neq b$
\ite...
...tem [{{*}}] $b\leftarrow b-a$
\item [{finsi}]~
\item [{fintantque}]~
\end{algor}

2.2.3 programme MAPLE

language=Maple,lineskip=-1pt,extendedchars=true,breaklines,numbers=left


\begin{lstlisting}
a:=rand(); b:=rand();
while (a<>b) do
if (a>b) then
a:=a-b;
else
b:=b-a;
end if;
end do:
a;
\par
\end{lstlisting}

2.2.4 programme Matlab

language=Matlab,lineskip=-1pt,extendedchars=true,breaklines,numbers=left


\begin{lstlisting}
a=round(1000*rand), b=round(1000*rand)
while (a~=b)
if (a>b)
a=a-b;
else
b=b-a;
end
end;
a
\par
\end{lstlisting}




Pr. Marc BUFFAT
marc.buffat@univ-lyon1.fr
2007-02-08