热门关键字:

返回值:

343
作者:管理员
发布时间:2020/7/16 17:00:00
评论数:0
转载请自觉注明原文:http://www.jq-school.com/Show.aspx?id=2141

函数返回值定义的结构在<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
友荐云推荐