April 2022 0 10 Report
Potrzebuję pomocy w programie napisanym w c++, który będzie mnożył ułamki zwykłe z wykorzystaniem NWD (algorytm Euklidesa). #include

using namespace std;


int NWD( int e, int f)
{
while (e!=0 && f!=0)
if (e>f) e=e%f;
else f=f%e;

if (e!=0) return e;
else return f;
}


void iloczyn(int a, int b, int c, int d)
{
int e, f, nwd_ef;

e = a/NWD(a,d) * c/NWD(b,c);
f = b/NWD(b,c) * d/NWD(a,d);

nwd_ef = NWD(e,f);

cout << e/nwd_ef << endl;
cout << f/nwd_ef << endl;
return 0;
}

Mam coś takiego ale nie działa. Czy jest jakaś dobra duszyczka, która wie jak to naprawić by działało? <3

Life Enjoy

" Life is not a problem to be solved but a reality to be experienced! "

Get in touch

Social

© Copyright 2013 - 2024 KUDO.TIPS - All rights reserved.