热门关键字:
jquery > jquery教程 > jquery教程 > C语言库函数之div()详解

C语言库函数之div()详解

325
作者:管理员
发布时间:2020/6/17 9:25:35
评论数:0
转载请自觉注明原文:http://www.jq-school.com/Show.aspx?id=1907
原函数:
div_t div(int numer, int denom)
函数说明:div_t div(int numer, int denom) 将numer (分子)除以 denom (分母)。
参数:
返回值:
函数返回值定义的结构在<cstdlib>,其中有两个成员。为 div_t:int quot; int rem;
如何使用div() 函数:
#include <stdio.h>
#include <stdlib.h>
int main() {
div_t output;
output = div(27, 4);
printf("Quotient part of (29/ 4) = %d \n", output.quot);
printf("Remainder part of (29/4) = %d \n", output.rem);
output = div(27, 3);
printf("Quotient part of (30/ 3) = %d \n", output.quot);
printf("Remainder part of (30/3) = %d \n", output.rem);
return(0);
编译和运行上面的程序,产生如下结果:
Quotient part of (29/ 4) = 7
Remainder part of (29/4) = 1
Quotient part of (30/ 3) = 10
Remainder part of (30/3) = 0




如果您觉得本文的内容对您的学习有所帮助:支付鼓励



关键字:div
友荐云推荐