//推断一个数的奇偶
#include <stdio.h>
int is_signal(int num)
{
if (num & 1)
return 1;
else
return -1;
}
int main()
{
int a;
printf("请输入:");
scanf_s("%d", &a);
if (is_signal(a)==1)
printf("奇数\n");
else
printf("偶数\n");
return 0;
}

【C语言】推断一个数的奇偶(位操作)的更多相关文章

  1. 【c语言】推断一个数是奇偶数

    // 推断一个数是奇偶数 #include <stdio.h> void judge_sd(int a) { if ((a & 1) == 0) { printf("是偶 ...

  2. 【c语言】推断一个数是不是2的n次方

    // 推断一个数是不是2的n次方 #include <stdio.h> void judge_n(int a) { int b = a - 1; if ((a & b) == 0) ...

  3. 【C语言】推断一个数是否为2的n次方

    //推断一个数是否为2的n次方 #include <stdio.h> int is_two_n(int num) { if ((num&(num - 1))) //去掉一个1,推断 ...

  4. YTU 2422: C语言习题 n个数逆序

    2422: C语言习题 n个数逆序 时间限制: 1 Sec  内存限制: 128 MB 提交: 150  解决: 96 题目描述 将n(n<20)个数按输入时顺序的逆序排列,用函数实现. 输入 ...

  5. C语言-实例3个数由小到大排序

    VS2012 //C语言实例 3个数由小到大排序 #include <stdio.h> void main() { int a, b, c, t; printf("Please ...

  6. c语言高速推断一个数是偶数还是奇数

    #include <stdio.h> int main() { int a; while(1) { printf("please input the number:\n" ...

  7. 【转载】C语言 构建参数个数不固定函数

    深入浅出可变参数函数的使用技巧本文主要介绍可变参数的函数使用,然后分析它的原理,程序员自己如何对它们实现和封装,最后是可能会出现的问题和避免措施. VA函数(variable argument fun ...

  8. c语言推断数是否是素数

    这是推断数是否是素数.网络版非常.我觉得有点问题.今天一个朋友问我这个问题.我知道,今天,我把自己的代码,非常实用哦!. #include<stdio.h> #include<mat ...

  9. c语言判断一个数是否为偶数

    #include <stdio.h> #include <stdbool.h> _Bool isOu(int n){ //高度注意:&的优先级低于== )==){ re ...

随机推荐

  1. expdp时遇到ORA-31693&amp;ORA-02354&amp;ORA-01466

    expdp时遇到ORA-31693&ORA-02354&ORA-01466 对一个schema运行expdp导出,expdp命令: nohup expdp HQ_X1/HQ_X1 DU ...

  2. JavaScript2谁刚开始学习应该知道4最佳实践文章(翻译)

    原版的:24 JavaScript Best Practices for Beginners (注:阅读原文的时候没有注意公布日期,觉得不错就翻译了,翻译到JSON.parse那一节觉得有点不正确路才 ...

  3. 常用PHP中花括号使用规则详解

    转自http://www.cnblogs.com/jayleke/archive/2011/11/08/2241609.html 1.简单句法规则(用花括号界定变量名,适用于PHP所有版本): $a ...

  4. SPOJ 7001(莫比乌斯反演)

    传送门:Visible Lattice Points 题意:0<=x,y,z<=n,求有多少对xyz满足gcd(x,y,z)=1. 设f(d) = GCD(a,b,c) = d的种类数 : ...

  5. SVN的switch命令

    语法就不说了,文档有的是,主要是两个常用的用法: . 切换资源库(svn sw --relocate) [plain] view plaincopy svn sw --relocate <fro ...

  6. 怎样在C++中获得完整的类型名称

    Wrote by mutouyun. (http://darkc.at/cxx-get-the-name-of-the-given-type/) 地球人都知道C++里有一个typeid操作符能够用来获 ...

  7. Cocos2d-x Layout简单使用

    1. Text* alert = Text::create("Layout", "fonts/Marker Felt.ttf", 30 ); alert-> ...

  8. 通信协议:HTTP、TCP、UDP(转)

    原文出处: 碧雪轩的博客 TCP   HTTP   UDP: 都是通信协议,也就是通信时所遵守的规则,只有双方按照这个规则“说话”,对方才能理解或为之服务. TCP   HTTP   UDP三者的关系 ...

  9. Android (1) - Activity

    onCreate(Bundle status) --> setContentView(View view) --> findViewById(int id) Intent intentFo ...

  10. ES6箭头函数和它的作用域

    原文来自我的前端博客: http://www.hacke2.cn/arrow-functions-and-their-scope/ http://es6rocks.com/2014/10/arrow- ...