cs_nomadstorm
Messages postés18Date d'inscriptiondimanche 27 décembre 2009StatutMembreDernière intervention15 mai 2011
-
31 janv. 2010 à 12:42
cs_ghuysmans99
Messages postés3982Date d'inscriptionjeudi 14 juillet 2005StatutMembreDernière intervention30 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;
}
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;
}
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);
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);