Programmation modulaie en c++

cs_nomadstorm Messages postés 18 Date d'inscription dimanche 27 décembre 2009 Statut Membre Dernière intervention 15 mai 2011 - 31 janv. 2010 à 12:42
cs_ghuysmans99 Messages postés 3982 Date d'inscription jeudi 14 juillet 2005 Statut Membre Dernière intervention 30 juin 2013 - 31 janv. 2010 à 13:32
bonjour tout le monde
j'ai besoin d'aide de la part des experts en programmation
car je veux utiliser 4 modules pour un programme de point et fraction
le 1 module contient l'affichage la saisie de point
et le 2 module contient le calcul de distance ,milieu
et les deux modules qui restent pour la fraction


voila les differents programme:
je vois plus ou es le probleme:


Code :
#include"dot.h"
#include
#include <cmath>

using namespace std;

void saisir_point(point &p)
{
cout << "Tapez l'abscisse du point : "; cin >> p.x;
cout << "Tapez l'ordonnée du point : "; cin >> p.y;
}

void afficher_point(point p)
{
cout << "Abscisse du point : " << p.x << endl;
cout << "Ordonnée du point : " << p.y << endl;
}

Code :

#ifndef POINT_H
#define POINT_H

struct point
{
double x,y;
};

void saisir_point(point &p);
void afficher_point(point p);

#endif


Code :
#include "fract.h"
#include
#include <cmath>

using namespace std;

void saisie_fract (fract &F)
{
cout<< "donnez la valeur de numerateur de la fraction "<<endl;
cin>>F.N;
cout<<endl;
cout<< "donnez la valeur de denominateur de la fraction "<<endl;
cin>>F.D;
cout<<endl;
}
void affichage_fract (fract F)
{
cout<<F.N<<"/"<<F.D<<endl;
cout<<endl;
}


Code :
#ifndef FRACT_H
#define FRACT_H

struct fract
{
double N,D;
};

void saisie_fract(fract &F);
void affichage_fract(fract F);


#endif


Code :
#include "fraction.h"
#include
#include <cmath>

using namespace std;

fract add_fract (fract A,fract B)
{
fract C;
C.N=((A.N*B.D)+(B.N*A.D));
C.D=A.D*B.D;
return (C);
}
fract diff_fract (fract A,fract B)
{
fract C;
C.N=((A.N*B.D)-(B.N*A.D));
C.D=A.D*B.D;
return (C);
}
fract pro_fract (fract A,fract B)
{
fract C;
C.N=A.N*B.N;
C.D=A.D*B.D;
return (C);
}
fract rapp_fract (fract A,fract B)
{
fract C;
C.N=A.N*B.D;
C.D=A.D*B.N;
return (C);
}
void reduct_fract(fract F,fract &M)
{ double x,y;
x=F.N;
y=F.D;
while (x!=y)
{
if (x>y)
x=x-y;
else
y=y-x;
}
M.N=F.N/x;
M.D=F.D/x;
cout<<"la reduction de la fraction "<<F.N<<"/"<<F.D<<"est:"<< M.N<<"/"<<M.D<<endl;
}

Code :
#ifndef FRACT_H
#define FRACT_H

struct fract
{
double N,D;
};


fract add_fract(fract A, fract B);
fract diff_fract(fract A, fract B);
fract pro_fract(fract A, fract B);
fract rapp_fract(fract A, fract B);
void reduct_fract(fract F,fract &M);

#endif

Code :
#include"point.h"
#include
#include <cmath>

using namespace std;

void distance(point a, point b)
{
double dx,dy,d;
dx = a.x - b.x;
dy = a.y - b.y;
d=sqrt( dx*dx + dy*dy );
cout << "La distance de X à Y est : " << d << endl;

}

void milieu(point a, point b, point &m)
{
m.x = (a.x + b.x) /2;
m.y = (a.y + b.y) /2;
}

Code :
#ifndef POINT_H
#define POINT_H

struct point
{
double x,y;
};

void distance(point a, point b);
void milieu(point a, point b, point &m);

#endif

Code :

#include "dot.h"
#include "point.h"
#include "fract.h"
#include "fraction.h"
#include
#include <cmath>
using namespace std;


int main()
{
fract a,b;
fract add,diff,pro,rapp;
fract ADD,DIFF,PRO,RAPP;

cout<<" saisie de la fraction F1 "<<endl;
saisie_fract (a);
cout<<" saisie de la fraction F2 "<<endl;
saisie_fract (b);
add =add_fract (a,b);
diff=diff_fract (a,b);
pro =pro_fract (a,b);
rapp=rapp_fract (a,b);

cout<<"votre fraction addition vaut "<<"=";

affichage_fract (add);
reduct_fract(add,ADD);
cout<< " FIN "<<endl;

cout<<"votre fraction difference vaut "<<"=";

affichage_fract (diff);
reduct_fract(diff,DIFF);
cout<< " FIN "<<endl;

cout<<"votre fraction produit vaut "<<"=";

affichage_fract (pro);
reduct_fract(pro,PRO);
cout<< " FIN "<<endl;
cout<<"votre fraction rapport vaut "<<"=";

affichage_fract (rapp);
reduct_fract(rapp,RAPP);
cout<< " FIN "<<endl;

point X,Y,Z;


cout << "SAISIE DE X" << endl;
saisir_point(X);

cout << "SAISIE DE Y" << endl;
saisir_point(Y);

// distance(X,Y);


milieu(X,Y,Z);
cout << "AFFICHAGE DU POINT Z" << endl;
afficher_point(Z);


system("PAUSE");
return 0;
}

1 réponse

cs_ghuysmans99 Messages postés 3982 Date d'inscription jeudi 14 juillet 2005 Statut Membre Dernière intervention 30 juin 2013 16
31 janv. 2010 à 13:32
Si tu ne te sers pas des class, autant coder en C !
---
VB.NET is good ... VB6 is better
0
Rejoignez-nous