using namespace std;void func(int a,int b,int x,int y);int main(){ int a,b,x,y; cout<<"請輸入第壹個數分子"<<endl; cin>>a; cout<<"請輸入第壹個數分母"<<endl; cin>>b; while (!b) { cout<<"分母不能為零"<<endl; cout<<"請輸入分母"<<endl; cin>>b; } cout<<"請輸入第二個數分子"<<endl; cin>>x; cout<<"請輸入第二個數分母"<<endl; cin>>y; while (!y) { cout<<"分母不能為零"<<endl; cout<<"請輸入分母"<<endl; cin>>y; } func(a,b,x,y); system("pause"); return 0; }void func(int a,int b,int x,int y){ if (b==y) { if (a>x) { cout<<a<<"/"<<b<<"大於"<<x<<"/"<<y<<endl; } else cout<<a<<"/"<<b<<"小於"<<x<<"/"<<y<<endl; } else { if (a*y>x*b) { cout<<a<<"/"<<b<<"大於"<<x<<"/"<<y<<endl; } else cout<<a<<"/"<<b<<"小於"<<x<<"/"<<y<<endl; }}