练习11

来源:互联网 发布:证件照软件 编辑:程序博客网 时间:2024/05/17 02:42
#include <iostream>
using namespace std;


typedef unsigned short int USHORT;
short int divide(USHORT a, USHORT b)
{
    if (b == 0)
          return -1;
    else
          return a/b;
}




int main()
{
    USHORT one, two;
    short int answer;
    cout << "Enter two numbers.\n Number one: ";
    cin >> one;
    cout << "Number two: ";
    cin >> two;
    answer = divide(one, two);
    if (answer > -1)
       cout << "Answer: " << answer;
    else
       cout << "Error, can't divide by zero!";
return 0;
}
原创粉丝点击