Bun venit Guest | RSS
Bine ati venit la 9C acasa
Meniul Site-ului
Horoscop
Exprima-ti opinia
Ce parere aveti despre site?
1. Foarte buna
2. Foarte proasta
3. Buna
4. Normal
5. Proasta
[ Vezi rezutat ยท Arhiva ]
Raspunsuri: 42
Mini chat

Info


Main » 2010 » Noiembrie » 26 » adunare si inmultire fractie cmmmc
adunare si inmultire fractie cmmmc
08:46
#include<iostream.h>
#include<math.h>

struct fractie{int num,nr;};
fractie *f1,*f2,*s,*p;



int cmmdc(int a, int b)
{
 int r;
while(b!=0)
{r=a%b;
a=b;
b=r;}
return a;
}

int cmmmc(int a, int b)
{
return (a*b)/cmmdc(a,b);
}

void main()
{f1=new fractie;
f2=new fractie;
s=new fractie;
p=new fractie;

cout<<"f1->nr= "; cin>>f1->nr;
cout<<"f1->num= "; cin>>f1->num;

cout<<"f2->nr= "; cin>>f2->nr;
cout<<"f2->num= "; cin>>f2->num;

cmmdc(f1->num,f2->num);

cout<<cmmdc(f1->num,f2->num)<<endl;

p->nr=(f1->nr * f2->nr);
p->num=(f1->num * f2->num);


int x=cmmmc(f1->num,f2->num)/f1->num;
int y=cmmmc(f1->num,f2->num)/f2->num;

s->nr=(f1->nr*x +f2->nr*y);
s->num=cmmmc(f1->num,f2->num) ;
int w=cmmdc(p->nr,p->num);
int z=cmmdc(s->nr,s->num);



cout<<"Suma "<<s->nr/z<<" / "<<s->num/z<<endl;
cout<<"Produs "<<p->nr/w<<" /"<<p->num/w<<endl;

delete f1,delete f2,delete s,delete p;
}

Views: 789 | Added by: Iulian
Only registered users can add comments.
[ Registration | Login ]
Logheaza-te
Calendar
«  Noiembrie 2010  »
DuLuMaMiJoViSa
 123456
78910111213
14151617181920
21222324252627
282930
Meteo
Curs Valutar
Curs Valutar BNR
Cautare
Link-uri
Statistica
Director web gratuit - Afisare Thumbnail, Transfer Google PageRank, Meta keywords si meta description personalizate pentru fiecare link Site clasei 9C Colegiul National Mihai Eminescu, Muzica Stiri Sport, Filme Top66 Statistici
Total online: 1
Guests: 1
Users: 0