Академический Документы
Профессиональный Документы
Культура Документы
x:rel
n:entier
retourne:rel
Dclaration de fonction
Syntaxe en notation algorithmique (cf. feuille rose )
x:rel
n:entier
retourne:rel
Comporte 3 parties :
Rsultat
renvoy
l'appelant
puissance
z-y
4
Programme Principal
Dclarations locales
|
....
|
Variables
|
|
x, y, z, rayon, teta, result : rel
Actions
|
.....
|
lire clavier x, y, z, rayon, teta
|
.....
|
z rayon * cos (teta)
{ z = rayon cos }
|
y 3 * abs ( z rayon )
{ y = 3 |z-rayon | }
|
result puissance(z-y, 4)
|
result x + result
{ result = x + (z-y)4 }
|
.....
Fin Actions
Syntaxe en C++
result
rect_pol
x:rel
y:rel
Dclaration de procdure
Syntaxe en notation algorithmique (cf. feuille rose)
|
|
|
| Dclarations
|
|
Constante
|
|
|
pi=3.14159
|
|
Variables
|
|
|
carre_module : rel
| Actions
|
|
carre_module x * x + y * y
|
|
rho racine_carree (carre_module)
|
|
Si (rho 0 ) Alors
|
|
|
|
teta arccos ( x / rho )
|
|
|
|
Si (y < 0) Alors
|
|
|
|
|
teta - teta
|
|
|
|
FSI
|
|
|
Sinon teta 0
|
|
FSI
| Fin Actions
Fin fonction % RectPol %
Pass par
Syntaxe en C++ (cf. feuille bleue)
rfrence :
sortie
Pass par
valeur : entre
void rectpol (float & rho, float & teta, float x, float y)
/*
cette procdure retourne les coordonnes polaires
rho et teta dun point dfini par son abscisse x et
Type vide
son ordonne y
!
*/
procdure
{
// dclarations locales
const float pi=3.14159;
float carre_module ;
// actions
carre_module = x*x + y*y ;
rho = sqrt ( carre_module) ;
if ( rho neq 0 )
{
teta = acos ( x / rho ) ;
if ( y < 0 ) teta = - teta ;
}
else teta = 0 ;
}
Il ne peut pas y avoir
d'instruction
return (valeur__retourner)
rect_pol
rho:rel
teta:rel
absA
ordA
x:rel
y:rel
rho:rel
teta:rel
rhoA
tetaA
Dclarations % globales %
|
|
... % dclaration de rectpol ici %
|
Programme principal
Dclarations % locales %
|
Variables
|
|
absA,ordA,absB,ordB,rhoA,tetaA, rhoB,tetaB : rel
Actions
|
crire cran "Entrez les coord. cartsiennes de A"
|
lire clavier absA, ordA
En notation
|
crire cran "Entrez les coord. cartsiennes de B"
algorithmique
|
lire clavier absB, ordB
l'appel est
|
appel rectpol (rhoA,tetaA,absA,ordA)
explicite
|
appel rectpol (rhoB,tetaB,absB,ordB)
|
crire cran "A : ", rhoA,",",tetaA, Fdl
Attention :
|
crire cran "B : ", rhoB,",",tetaB, Fdl
Le mode de passage
Fin Actions
des paramtres n'est
jamais indiqu au
Syntaxe en C++
niveau de l'appel
// dclarations de la procdure recpol
.... /* voir ci-dessus 3.2 */
// programme principal
main ()
{
// variables
float absA,ordA,absB,ordB,rhoA,tetaA, rhoB,tetaB;
// actions
cout << "Entrez les coord. cartsiennes de A ";
cin >> absA >> ordA;
cout << "Entrez les coord. cartsiennes de B ";
cin >> absB >> ordB;
rectpol (rhoA,tetaA,absA,ordA) ;
rectpol (rhoB,tetaB,absB,ordB) ;
Appel en
ce C;et
cout << "A:"<<rhoA<<","<<tetaA<<endl;
C++ :
cout << "B:"<<rhoB<<","<<tetaB<<endl;
nom de la
}
procdure
Attention :
suivi de la
Le mode de passage
liste des
des paramtres n'est
paramtres
jamais indiqu au
effectifs
niveau de l'appel