日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

c语言 div ldiv_C ++中带有示例的ldiv()函数

發布時間:2025/3/11 编程问答 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 c语言 div ldiv_C ++中带有示例的ldiv()函数 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

c語言 div ldiv

C ++ ldiv()函數 (C++ ldiv() function)

ldiv() function is a library function of cstdlib header. It is used for integral division, it accepts two parameters (numerator and denominator) and returns a structure that contains the quot (quotient) and rem (remainder).

ldiv()函數是cstdlib標頭的庫函數。 它用于整數除法,它接受兩個參數( 分子和分母 ),并返回一個包含quot ( 商 )和rem ( remaind )的結構。

Syntax of ldiv() function:

ldiv()函數的語法:

C++11:

C ++ 11:

ldiv_t ldiv (long int numer, long int denom);

Parameter(s):

參數:

  • numer – represents the value of numerator.

    numer –代表分子的值。

  • denom – represents the value of denominator.

    denom –代表分母的值。

Return value:

返回值:

The return type of this function is ldiv_t, returns a structure that contains the quot (quotient) and rem (remainder).

該函數的返回類型為ldiv_t ,返回一個包含quot ( quotient )和rem ( 其余部分 )的結構。

Example:

例:

Input:long int n = 123456789;long int d = 12345678;ldiv_t result;Function call:result = ldiv(n, d);Output:result.quot = 10result.rem = 9

C ++代碼演示ldiv()函數的示例 (C++ code to demonstrate the example of ldiv() function)

// C++ code to demonstrate the example of // ldiv() function#include <iostream> #include <cstdlib> using namespace std;// main() section int main() {long int n = 123456789;long int d = 12345678;ldiv_t result;result = ldiv(n, d);cout << "Numerator : " << n << endl;cout << "Denominator: " << d << endl;cout << "Quotient : " << result.quot << endl;cout << "Remainder : " << result.rem << endl;cout << endl;n = 999988887777;d = 1112223334;result = ldiv(n, d);cout << "Numerator : " << n << endl;cout << "Denominator: " << d << endl;cout << "Quotient : " << result.quot << endl;cout << "Remainder : " << result.rem << endl;cout << endl;n = 100100234;d = 9878762536;result = ldiv(n, d);cout << "Numerator : " << n << endl;cout << "Denominator: " << d << endl;cout << "Quotient : " << result.quot << endl;cout << "Remainder : " << result.rem << endl;cout << endl;return 0; }

Output

輸出量

Numerator : 123456789 Denominator: 12345678 Quotient : 10 Remainder : 9Numerator : 999988887777 Denominator: 1112223334 Quotient : 899 Remainder : 100110511Numerator : 100100234 Denominator: 9878762536 Quotient : 0 Remainder : 100100234

Reference: C++ ldiv() function

參考: C ++ ldiv()函數

翻譯自: https://www.includehelp.com/cpp-tutorial/ldiv-function-with-example.aspx

c語言 div ldiv

總結

以上是生活随笔為你收集整理的c语言 div ldiv_C ++中带有示例的ldiv()函数的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。