1.10 phan so toi gian

/*1_10 Nhap tu so mau so, tim dang phan so toi gian*/

#include<stdio.h>

#include<conio.h>

#include<math.h>

int a,b,r;

int ucln(int a,int b);

void main()

{

printf("Nhap vao tu so:

");

scanf("%d",&a);

printf("Nhap vao mau so:

");

scanf("%d",&b);

printf("Phan so toi gian la %d/%d", a/ucln(a,b), b/ucln(a,b));

getch();

}

int ucln(int a,int b)

{

if(a>b)

do

{

r=a%b;

a=b;

b=r;

}

while(r!=0);

if(a<b)

do

{

r=b%a;

b=a;

a=r;

}

while(r!=0);

return b;

}

Bạn đang đọc truyện trên: truyentop.pro

Tags: #education