程序清单2.6 convert.cpp

// convert.cpp -- converts stone to pounds

#include <iostream>

int stonetolb(int);

int main()
{
    using namespace std;

    int stone;
    cout << "Enter the weight in stone: ";
    cin >> stone;
    int pounds = stonetolb(stone);
    cout << stone << " stone = ";
    cout << pounds << " pounds." << endl;

    return 0;
}

int stonetolb(int sts)
{
    return 14 * sts;
}

输出:

Enter the weight in stone: 12
12 stone = 168 pounds.

猜你喜欢

转载自blog.csdn.net/m0_38101326/article/details/88044615
cpp