作者热门文章
- mongodb - 在 MongoDB mapreduce 中,如何展平值对象?
- javascript - 对象传播与 Object.assign
- html - 输入类型 ="submit"Vs 按钮标签它们可以互换吗?
- sql - 使用 MongoDB 而不是 MS SQL Server 的优缺点
最佳答案
div
会这样做。见 reference和例子:
/* div example */
#include <stdio.h>
#include <stdlib.h>
int main ()
{
div_t divresult;
divresult = div (38,5);
printf ("38 div 5 => %d, remainder %d.\n", divresult.quot, divresult.rem);
return 0;
}
输出:
38 div 5 => 7, remainder 3.
编辑:
C 规范说:
The types declared are size_t and wchar_t (both described in 7.17),
div_t
which is a structure type that is the type of the value returned by the div function,
ldiv_t
which is a structure type that is the type of the value returned by the ldiv function, and
lldiv_t
which is a structure type that is the type of the value returned by the lldiv function.
...但没有说明div_t
的定义是什么。
关于c++ - 如何一步获得商和余数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8318272/
我是一名优秀的程序员,十分优秀!