兩數除法(判斷大小及除數是否為0)
#include#include using namespace std; int main(void) { int a, b; cout << "請輸入二個整數數值,以空白分隔:"; cin >> a >> b; if(a >= b) { if(b == 0) cout << "除數為 0\n"; else cout << a << " / " << b << " = " << (float)a/(float)b << endl; } else { if(a == 0) cout << "除數為 0\n"; else cout << b << " / " << a << " = " << (float)b/(float)a << endl; } return 0; }