C ++ CLI中的MOD和DIV [英] MOD and DIV in C++ CLI
问题描述
大家好!我是C ++ / CLI的菜鸟,我想问一个小问题:
我需要得到两个整数变量A和B的MOD和DIV ,
如何用正确的语法和 A = A(MOD)B和A = A(DIV)B 我应该在我的代码中添加一个特殊的标题才能使用它们!???谢谢
% - mod
/ - div
int i1 = 5 % 2 跨度>; // i1 == 1
int i2 = 5 / 2 ; // i2 == 2
< blockquote>虽然Simon完全正确,但也有
ldiv_t ldiv(long int numerator,long int denominator);
它将分子除以分子的整数商和余数作为 ldiv_t
类型的结构,这个结构有两个成员quot和rem。如果你需要这两个结果,调用ldiv会更有效率。
最好的问候
Espen Harlinn
Hi everyone! I am a noob in C++/CLI, I d like to ask a small question:
I need to get the MOD and the DIV of two integer variables A and B,
How can I do A=A(MOD)B and A=A(DIV)B in the right syntax and... should I add an special header to my code in order to use these!??? THANKS
% - mod
/ - div
int i1 = 5 % 2; // i1 == 1 int i2 = 5 / 2; // i2 == 2
While Simon is entirely right there is also
ldiv_t ldiv ( long int numerator, long int denominator );
Which returns the integral quotient and remainder of the division of numerator by denominator as a structure of typeldiv_t
, this structure has two members quot and rem. If you need both results calling ldiv is more efficient.
Best regards
Espen Harlinn
这篇关于C ++ CLI中的MOD和DIV的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!