面试宝典之程序设计基本概念
来源:互联网 发布:网络兼职骗局信誉代刷 编辑:程序博客网 时间:2024/05/01 19:01
#include <stdio.h>int i = 1;int main(void){int i = i;int a = a;printf("%d\n",i);printf("%d\n",a);return 0;}
输出结果:
------------------------------------------------------------------------------------------------------------------------------------------------------------------
#include <iostream>using namespace std;int main(void){int x = 2, y, z;x *= (y = z = 5); cout << x << endl;z = 3;x == (y = z); cout << x << endl;x = (y == z); cout << x << endl;x = (y&z); cout << x << endl;x = (y && z); cout << x << endl;y = 4;x = (y | z); cout << x << endl;x = (y || z); cout << x << endl;return 0;}
输出结果:
注意:书上的结果缺少了最后面的那个1
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
#include <iostream>using namespace std;int func(int x){int count = 0;while(x){count ++;x = x&(x-1);}return count;}int main(void){cout << func(9999) << endl;return 0;}
输出结果:
因为9999的二进制为:
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#include <iostream>using namespace std;int main(void){int a, x;for (a = 0, x = 0; a <= 1 && !x++; a++){a++;}cout << a << x << endl;return 0;}
#include <iostream>using namespace std;int main(void){int a, x;for (a = 0, x = 0; a <= 1 && !x++;){a++;}cout << a << x << endl;return 0;}
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#include <stdio.h>int main(void){int b = 3;int i = 0;int arr[] = {6, 7, 8, 9, 10};signed int *ptr = arr;*(ptr++) += 123;printf("%d, %d\n", *ptr, *(++ptr));for (i = 0; i < 5; i++){printf("%d\n", arr[i]);}return 0;}
结果为:
----------------------------------------------------------------------------------------------------------------------------------------------------------------------
#include <stdio.h>int main(void){unsigned int a = 0xFFFFFFF7;unsigned char i = (unsigned char )a;char *b = (char *)&a;printf("%08x, %08x", i, *b);return 0;}
结果为:
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
#include <iostream>//#include <stdio.h>//#include <string.h>//#include <conio.h>using namespace std;int main(void){float a = 1.0f;cout << (int )a << endl;cout << &a << endl;cout << (int &)a << endl;cout << boolalpha << ((int) a == (int &)a) << endl;float b = 0.0f;cout << (int )b << endl;cout << &b << endl;cout << (int &)b << endl;cout << boolalpha << ((int) b == (int &)b) << endl;return 0;}
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
#include <iostream>#include <stdio.h>using namespace std;int main(void){unsigned char a = 0xA5;unsigned char b = ~a >> 4 + 1;cout << b << endl;printf("%d\n", b);return 0;}
注意:
cout << b << endl;
输出的为不可见字符。
- 面试宝典之程序设计基本概念
- 程序员面试宝典_程序设计基本概念
- 程序员面试宝典第五章 程序设计基本概念
- 面试宝典---java程序设计的基本概念
- 程序员面试宝典 第5章:程序设计基本概念
- 程序员面试精要-C/C++程序设计-程序设计基本概念(面试宝典读书笔记)
- 面试宝典5,6,7--程序设计基本概念;预处理、const与sizeof;指针与引用
- 程序猿面试宝典(第三版)——程序设计基本概念--我应学习
- 【Java】Java程序员面试宝典(第三版)第5章----Java程序设计基本概念
- 程序员面试宝典(第四版)——读书笔记-1、第五章:程序设计基本概念
- SQL 之面试宝典
- 面试宝典之java
- 面试宝典之数据结构
- 高级程序员之面试宝典
- 程序员求职之道(《程序员面试笔试宝典》)之程序设计基础(static的使用)?
- 程序员求职之道(《程序员面试笔试宝典》)之程序设计基础(内存分配形式)?
- 程序员求职之道(《程序员面试笔试宝典》)之程序设计基础(内存分配形式)?
- 程序员求职之道(《程序员面试笔试宝典》)之程序设计基础(static的使用)?
- J2EE开发时的包命名规则,养成良好的开发习惯
- 大趋势(一):软件化 / Software Defined
- ffmpeg+ffserver 搭建流媒体服务器
- SQL中的 where 1= 1?以及select 1 from table?意义!
- 怎样判断机器的字节顺序是高字节在前还是低字节在前?
- 面试宝典之程序设计基本概念
- Objective-C 类和对象
- android 的injustdecodebounds
- oracle中的包头(Package)与包体(Package body)
- 解决:彩信,添加了有效联系人和编辑了主题,按返回键,提示信息存为草稿,但实际未储存
- Log4Net使用指南
- 在SQL PLUS中打印存储过程的结果
- 如何使用web.xml配置参数,并在serlvet取得该值
- c语言结构体自引用指针