知识库

C++语言开发示例:01. 余数

2025-02-01 20:23:27 李腾 1 次阅读

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";
}
转载请注明转自www.hylab.cn,原文地址:C++语言开发示例:01. 余数

评论 (0)

登录后发表评论

暂无评论,快来发表第一条评论吧!