該函數查找分子/分母的浮點餘數(四舍五入到最接近的整數值),並將商內部存儲到函數參數中傳遞的指針。
用法
假設分子為'n',分母為'd',指針為'p'。語法是:
return_type remquo(data_type n, data_type d, int* p);
注意:return_type 可以是 float、double 或 long double。
參數
n:分子的值。
d:分母的值。
p:指向內部存儲商的對象的指針。
返回值
它返回浮點餘數 n/d。
例子1
當參數類型相同時,讓我們看一個簡單的例子。
#include <iostream>
#include<math.h>
using namespace std;
int main()
{
float x=7.6;
float y=5.4;
int* p;
std::cout << "Value of remainder is:" << remquo(x,y,p)<<'\n';
cout<<"Value of quotient is:"<<*p;
return 0;
}
輸出:
Value of remainder is:2.2 Value of quotient is:1
例子2
當參數是不同類型時,讓我們看一個簡單的例子。
#include <iostream>
#include<math.h>
using namespace std;
int main()
{
int x=2;
float y=1.1;
int* q;
std::cout << "Value of remainder is:" <<remquo(x,y,q)<<'\n';
cout<<"Value of quotient is:"<<*q;
return 0;
}
輸出:
Value of remainder is:0.2 Value of quotient is:2
相關用法
- C++ Math remainder()用法及代碼示例
- C++ Math rint()用法及代碼示例
- C++ Math round()用法及代碼示例
- C++ Math scalbn()用法及代碼示例
- C++ Math acosh()用法及代碼示例
- C++ Math asinh()用法及代碼示例
- C++ Math isgreater()用法及代碼示例
- C++ Math fabs()用法及代碼示例
- C++ Math islessgreater()用法及代碼示例
- C++ Math log2()用法及代碼示例
- C++ Math nearbyint()用法及代碼示例
- C++ Math tan()用法及代碼示例
- C++ Math log()用法及代碼示例
- C++ Math nextafter()用法及代碼示例
- C++ Math fdim()用法及代碼示例
- C++ Math isfinite()用法及代碼示例
- C++ Math erfc()用法及代碼示例
- C++ Math sinh()用法及代碼示例
- C++ Math scalbln()用法及代碼示例
- C++ Math cosh()用法及代碼示例
注:本文由純淨天空篩選整理自 C++ Math remquo()。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。