完成函数。参数为两个unsigned short int型数﹐返回值为第一个参数除以第二个参数的结果,数据类型为short int;如果第二个参数为0,则返回值为一1。在主程序中实现输人输出。
1 #include<iostream> 2 #include<ctime> 3 using namespace std; 4 5 short int fun(unsigned short int a, unsigned short int b){ 6 if(b == 0) return -1; 7 return a / b; 8 } 9 int main(){ 10 unsigned short int a,b; 11 cout<<"请输入两个数"<<endl; 12 cin>>a>>b; 13 cout<<fun(a, b)<<endl; 14 return 0; 15 }
标签:,short,return,cout,int,unsigned,参数 From: https://www.cnblogs.com/YUZE2001/p/17204474.html