当前在线人工客服
天达云-技术
QQ:1324027256
天达云-技术
QQ:1902643386
天达云-售前
QQ:1650874901
天达云-售前
QQ:2207995833
天达云-合作
QQ:1984186903
天达云微信小程序
400-837-6568

C语言的div()函数实例分析
更新:HHH   时间:2023-1-7


本文小编为大家详细介绍“C语言的div()函数实例分析”,内容详细,步骤清晰,细节处理妥当,希望这篇“C语言的div()函数实例分析”文章能帮助大家解决疑惑,下面跟着小编的思路慢慢深入,一起来学习新知识吧。

原函数:

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

读到这里,这篇“C语言的div()函数实例分析”文章已经介绍完毕,想要掌握这篇文章的知识点还需要大家自己动手实践使用过才能领会,如果想了解更多相关内容的文章,欢迎关注天达云行业资讯频道。

返回web开发教程...