Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // rut gon phan so
- // Khai bao cac ham thu vien neu co
- #include<stdio.h>
- #include<conio.h>
- #include<math.h>
- int ucln(int a,int b);
- void main()
- {
- // tu so va mau so deu khac 0
- int tuso,mauso;
- scanf("%d%d",&tuso,&mauso);
- int x=abs(tuso);
- int y=abs(mauso);
- int t=ucln(x,y);
- if(mauso<0)
- {
- printf("%d / %d\n", (-tuso/t),(y/t));
- }
- else
- {
- if((y/t)==1)
- {
- printf("%d\n",(tuso/t));
- }
- else
- {
- printf("%d / %d\n", (tuso/t),(y/t));
- }
- }
- }
- int ucln(int a,int b)
- {
- while(a!=b)
- {
- if(a>b)
- {
- a=a-b;
- }
- else
- {
- b=b-a;
- }
- }
- return a;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement