C 库函数 - ldiv()

C 语言教程 · 2019-02-24 10:43:20

描述

C 库函数 div_t div(long int numer, long int denom)numer(分子)除以 denom(分母)

声明

下面是 ldiv() 函数的声明。

div_t div(long int numer, long int denom)

参数

  • numer -- 分子。
  • denom -- 分母。

返回值

该函数返回定义在 <cstdlib> 中的结构中的值,该结构有两个成员,如 ldiv_t:long quot; long rem;

实例

下面的实例演示了 ldiv() 函数的用法。

#include <stdio.h>
#include <stdlib.h>

int main ()
{
   ldiv_t output;

   output = ldiv(100000L, 30000L);

   printf("商 = %ld\n", output.quot);

   printf("余数 = %ld\n", output.rem);
   
   return(0);
}

让我们编译并运行上面的程序,这将产生以下结果:

商 = 3
余数 = 10000

点击查看所有 C 语言教程 文章: https://codercto.com/courses/l/17.html

查看所有标签

Geometric Folding Algorithms

Geometric Folding Algorithms

Erik D Demaine / Cambridge University Press / 2008-8-21 / GBP 35.99

Did you know that any straight-line drawing on paper can be folded so that the complete drawing can be cut out with one straight scissors cut? That there is a planar linkage that can trace out any alg......一起来看看 《Geometric Folding Algorithms》 这本书的介绍吧!

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码

MD5 加密
MD5 加密

MD5 加密工具

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试