C++ STL 中的 lldiv() 函数
C++ STL 中的 lldiv() 函数给出两个数字相除的商和余数。
算法
Begin Take two long type numbers as input. Call function lldiv(). Print the quotient and remainder. End.
示例代码
#include <cstdlib>
#include <iostream>
using namespace std;
int main() {
long long q = 500LL;
long long r = 25LL;
lldiv_t res = lldiv(q, r);
cout << "Quotient of " << q << "/" << r << " = " << res.quot << endl;
cout << "Remainder of " << r << "/" << r << " = " << res.rem << endl;
return 0;
}输出
Quotient of 500/25 = 20 Remainder of 25/25 = 0
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 语言编程
C++
C#
MongoDB
MySQL
Javascript
PHP