这个数字很奇怪? [英] The number is odd?

查看:79
本文介绍了这个数字很奇怪?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

如何验证C ++中的数字是否为奇数?


谢谢你,最好的问候。

加埃塔诺

Hi to all,
How can verify if a number is odd in C++?

Thank You and best Regards.
Gaetano

推荐答案

nick048< ni ************* @ moonsoft.itwrote:
nick048 <ni*************@moonsoft.itwrote:

大家好,

如何验证C ++中的数字是否为奇数?
Hi to all,
How can verify if a number is odd in C++?



如果数字是标量,那么你可以这样做:


bool odd = !!(数字& 1);


david

If the number is a scalar, then you can do this:

bool odd = !!(number & 1);

david




nick048写道:

nick048 wrote:

大家好,

如何验证C ++中的数字是否为奇数?


谢谢你,最好的问候。

加埃塔诺
Hi to all,
How can verify if a number is odd in C++?

Thank You and best Regards.
Gaetano



你可以像大卫建议的那样做 - 或者更喜欢不那么模糊(和

一样快)

数字%2!= 0

/ Peter

You can do as David suggested - or prefer the less obscure (and at
least as fast)
number % 2 != 0

/Peter




david写道:

david wrote:

nick048< ni ************* @ moonsoft.itwrote:
nick048 <ni*************@moonsoft.itwrote:

大家好,

如何验证C ++中的数字是否为奇数?
Hi to all,
How can verify if a number is odd in C++?



如果数字是标量,那么你可以这样做:


bool odd = !!(数字& 1);


david


If the number is a scalar, then you can do this:

bool odd = !!(number & 1);

david



为什么!! ?

Why !! ?


这篇关于这个数字很奇怪?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆