當前位置:編程學習大全網 - 編程軟體 - 壹道c++編程題 求大神解答!急!

壹道c++編程題 求大神解答!急!

#include <iostream>

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; }}

  • 上一篇:數據結構算法在php編程中的作用
  • 下一篇:面試想吊打面試官?阿裏架構師教妳吃透Spring(Boot、Cloud、MVC)
  • copyright 2024編程學習大全網