C++ 实例 - 求商及余数
C++ 教程
· 2019-02-26 10:43:02
使用 C++ 获取用户的输入两个数字,并将两个数字相除,然后将商和余数输出到屏幕:
实例
#include <iostream>
using namespace std;
int main()
{
int divisor, dividend, quotient, remainder;
cout << "输入被除数: ";
cin >> dividend;
cout << "输入除数: ";
cin >> divisor;
quotient = dividend / divisor;
remainder = dividend % divisor;
cout << "商 = " << quotient << endl;
cout << "余数 = " << remainder;
return 0;
}
以上程序执行输出结果为:
输入被除数: 13 输入除数: 4 商 = 3 余数 = 1
点击查看所有 C++ 教程 文章: https://codercto.com/courses/l/18.html
The Black Box Society
Frank Pasquale / Harvard University Press / 2015-1-5 / USD 35.00
Every day, corporations are connecting the dots about our personal behavior—silently scrutinizing clues left behind by our work habits and Internet use. The data compiled and portraits created are inc......一起来看看 《The Black Box Society》 这本书的介绍吧!