éxposant en CPP

Résolu
ffnajia Messages postés 30 Date d'inscription mercredi 12 avril 2006 Statut Membre Dernière intervention 17 avril 2007 - 12 avril 2006 à 08:13
magic_Nono Messages postés 1878 Date d'inscription jeudi 16 octobre 2003 Statut Membre Dernière intervention 16 mars 2011 - 13 avril 2006 à 15:43
Bonjour,
je sais pas comment faire x à la puissance y en C++?!!! x**y ne marche pas, ni x^y, alors comment?


Merci à tous
Najia

5 réponses

mogwai93 Messages postés 362 Date d'inscription mardi 31 décembre 2002 Statut Membre Dernière intervention 4 novembre 2023
12 avril 2006 à 09:34
tu as aussi la methode que l'on voit à l'ecole :

x^y = exp( y * ln (x) )

avec x > 0
3
platon179 Messages postés 237 Date d'inscription lundi 20 mai 2002 Statut Membre Dernière intervention 22 juillet 2011 2
12 avril 2006 à 08:19
Salut :)

Un petit #include <cmath> avec un using namespace std; après tes includes

Puis un appel a la fonction pow : par exemple, pour 4^3 : double res = pow(4.0, 3.0);

Voilà, bonne journée @++
0
ffnajia Messages postés 30 Date d'inscription mercredi 12 avril 2006 Statut Membre Dernière intervention 17 avril 2007
12 avril 2006 à 16:30
merci platon179 , ca marche ce que tu m'a écrit, mais ce que je veux c'est la fontion générale, x^y, une fonction à la puissance une autre!!!


Merci
Najia
0
ffnajia Messages postés 30 Date d'inscription mercredi 12 avril 2006 Statut Membre Dernière intervention 17 avril 2007
12 avril 2006 à 16:31
merci mogwai93
cette méthode ca reste limité pour x >0
et si c'est négatif???!!!


Merci
Najia
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
magic_Nono Messages postés 1878 Date d'inscription jeudi 16 octobre 2003 Statut Membre Dernière intervention 16 mars 2011
13 avril 2006 à 15:43
[Visual Basic]
Public Shared Function Pow( _
ByVal x As [frlrfsystemdoubleclasstopic.htm Double], _
ByVal y As [frlrfsystemdoubleclasstopic.htm Double] _
) As [frlrfsystemdoubleclasstopic.htm Double]
[C#]
public static [frlrfsystemdoubleclasstopic.htm double] Pow(
[frlrfsystemdoubleclasstopic.htm double] x,
[frlrfsystemdoubleclasstopic.htm double] y
);
[C++]
public: static [frlrfsystemdoubleclasstopic.htm double] Pow(
[frlrfsystemdoubleclasstopic.htm double] x,
[frlrfsystemdoubleclasstopic.htm double] y
);
[JScript]
public static function Pow(
x : [frlrfsystemdoubleclasstopic.htm double],
y : [frlrfsystemdoubleclasstopic.htm double]
) : [frlrfsystemdoubleclasstopic.htm double];


Parameters

* x : A number to be raised to a power.
* y : <dd>A number that specifies a power.

Return Value

The number x raised to the power y.

(source : MSDN)
___________________________________________________________
Magicalement
Nono
0
Rejoignez-nous