Вы находитесь на странице: 1из 3

//***** Fichier source .

cpp

#include <iostream>

#include "Complexe.h"
#include "vecteur.h"

using namespace std;

//Exercice 1:
/*
int main ()
{
Complexe Nb;
Nb.Init(2.5, 1.75);
Nb.Calcul();
Nb.Display();

*/

// Exercice 2:

/*

int main( )
{

int b=20;

float Pu;

vecteur v (b);

Pu=v.calcul();

cout <<"La puissance du l'objet est : "<<Pu<< endl;

*/

//****** Fichier Complexe.h


#include <string>

#include <iostream>

using namespace std;

class Complexe
{

long double a, b, mod, phas;

public:

void Init(long double x, long double y)


{
a=x;
b=y;
}

void Calcul ()
{

mod = sqrt((a*a)+(b*b));
phas=atan(b/a);

void Display ()
{

cout << "\n Partie reelle = "<<a<<endl;


cout << "\n Partie imaginaire = "<<b<<endl;
cout << "\n Module= "<<mod<<endl;
cout << "\n Phase= "<<phas<<endl;

};

//************* Fichier Vecteur.h

#include <string>

#include <iostream>

using namespace std;


// classe vecteur:

class vecteur
{
int a;
float *vect;
public:

vecteur (int b);

float calcul();

};

vecteur::vecteur (int b)
{

a=b;
vect= new float[a];
for (int i=0; i <a; i++)
vect[i]=(rand()%100)*0.5;
}

float vecteur::calcul()
{

float P=0;
for (int i=0; i<a; i++){
P+=(vect[i]*vect[i]);
}
P=(P/a);

return P;
}

Вам также может понравиться