fork download
  1.  
  2.  
  3. #include<bits/stdc++.h>
  4. using namespace std;
  5.  
  6. struct PhanSo{
  7. int x,y;
  8. };
  9.  
  10. void nhap(PhanSo &a,PhanSo &b){
  11. cin>>a.x>>a.y;
  12. cin>>b.x>>b.y;
  13. }
  14.  
  15. int sosanh(PhanSo a,PhanSo b)
  16. {
  17. if(a.x*b.y == a.y*b.x ) return 0;
  18. else if( a.x*b.y < a.y*b.x) return 1;
  19. return -1;
  20. }
  21.  
  22. void xuat(PhanSo a,PhanSo b){
  23. if(sosanh(a,b)==1){
  24. cout<<"Phan So thu hai lon hon phan so thu nhat";
  25.  
  26. }
  27. else if(sosanh(a,b)==0){
  28. cout<<"hai phan so bang nhau";
  29.  
  30. }
  31. else{
  32. cout<<"phan so thu hai nho hon phan so thu nhat";
  33. }
  34. }
  35.  
  36. int main()
  37. {
  38. PhanSo a,b;
  39. nhap(a,b);
  40. xuat(a,b);
  41. }
  42.  
Success #stdin #stdout 0.01s 5436KB
stdin
1 2 2 4
stdout
hai phan so bang nhau