Mọi người xem dùm em code em sai chỗ nào ạ
#include "stdio.h"
struct PHANSO
{
int tu;
int mau;
};
int UCLN(int a, int b) //Thuat Toan Euclide
{
if (a%b == 0)
return b;
else
return UCLN(b, a%b);
}
void CongPS(PHANSO *&ps1, PHANSO *&ps2, PHANSO *&ps)
{
(ps->tu) = (ps1->tu) * (ps2->mau) + (ps2->tu) * (ps1->mau);
(ps->mau) = (ps1->mau) * (ps2->mau);
(ps->tu) = (ps->tu) / UCLN((ps->tu), (ps->mau));
(ps->mau) = (ps->mau) / UCLN((ps->tu), (ps->mau));
}
int main()
{
struct PHANSO *ps1, *ps2, *ps;
printf("Nhap Phan So Thu 1: \n");
printf("Tu = ");
scanf("%d", ps1 -> tu);
do{
printf("Mau = ");
scanf("%d", ps1->mau);
} while (ps1->mau == 0);
printf("Nhap Phan So Thu 2: \n");
printf("Tu = ");
scanf("%d", ps2->tu);
do{
printf("Mau = ");
scanf("%d", ps1->mau);
} while (ps1->mau == 0);
printf("Cong Hai Phan So %d/%d Va %d/%d La: %d/%d", ps1->tu, ps1->mau, ps2->tu, ps2->mau, ps->tu, ps->mau);
return 0;
}