MY name is ruhul amin

ISLAMIC UNIVERSITY OF KUSHTIA

Wednesday, March 13, 2013

uva solve problem 834 - Continued Fractions

#include<stdio.h>
int main()
{
    long long int n,a,b,c,x,y;
    while(scanf("%lld%lld",&a,&b)==2)
    {
        n=a/b;
        printf("[%lld;",n);
        c=a%b;
        while(c!=0)
        {
            x=b;
            y=c;
            n=x/y;
            printf("%lld",n);
            c=x%y;
            if(c>0)
            printf(",");
            b=y;

        }
        printf("]\n");
    }
    return 0;
}

No comments:

Post a Comment