求商

求出两个整数相除后的商。
注意:

如果分母为0,输出Error:the divisor cannot be 0.
否则输出Quotient is xxx

测试举例:
测试输入:3 0
预期输出:Error:the divisor cannot be 0.
测试输入:12 4
预期输出:Quotient is 3

#include <iostream>
using namespace std;
int main()
{
 int a,b=0;
 cin>>a>>b;
 if(b==0)
 {
  cout<<"Error:the divisor cannot be 0."<<endl;
 }
 else
 {
  cout<<"Quotient is "<<a/b<<endl;
 }
}
发布了102 篇原创文章 · 获赞 93 · 访问量 4989

猜你喜欢

转载自blog.csdn.net/huangziguang/article/details/104557693