Hi
I'm having trouble with the z-easy problem my code works perfectly when I compile it.
But when i send it i get WRONG RESULT for all of them.
can someone help with this :
Here is my C code:
#include <stdio.h>
long gcd(long a,long b);
int main(void)
{
long a,b,c,d;
scanf("%li/%li",&a,&b);
scanf("%li/%li",&c,&d);
long m=a*d+c*b;
long n=b*d;
long g_c_d=gcd(m,n);
printf("%li/%li\n",m/g_c_d,n/g_c_d);
return 0;
}
long gcd(long a,long b)
{
return (b==0?a:gcd(b,a%b));
}
Thanks a lot
I'm having trouble with the z-easy problem my code works perfectly when I compile it.
But when i send it i get WRONG RESULT for all of them.
can someone help with this :
Here is my C code:
#include <stdio.h>
long gcd(long a,long b);
int main(void)
{
long a,b,c,d;
scanf("%li/%li",&a,&b);
scanf("%li/%li",&c,&d);
long m=a*d+c*b;
long n=b*d;
long g_c_d=gcd(m,n);
printf("%li/%li\n",m/g_c_d,n/g_c_d);
return 0;
}
long gcd(long a,long b)
{
return (b==0?a:gcd(b,a%b));
}
Thanks a lot