01. 余数

创建日期:2024-07-11
更新日期:2025-02-01

modulus.cpp

#include <iostream>

int main()
{
    using namespace std;
    const int Lbs_per_stn = 14;
    int lbs;

    cout << "Enter your weight in pounds: ";
    cin >> lbs;
    int stone = lbs / Lbs_per_stn;
    int pounds = lbs % Lbs_per_stn;
    cout << "lbs"
         << " pounds are " << stone
         << " stone, " << pounds << " pound(s).\n";
}