[面試題]C符號的優先順序
int x = 0;
if (x = 0 || x == 0) printf("%dn", x);
printf("%dn", x);- 參考C的優先表, 其實就是if (x = (0 || x == 0))
會printf出兩個1.同一优先级的运算符,运算次序由结合方向所决定。
简单记就是:! > 算术运算符 > 关系运算符 > && > || > 赋值运算符
C Operator Precedence Table
This page lists C operators in order of precedence (highest to lowest). Their associativity indicates in what order operators of equal precedence in an expression are applied.
Operator
Description Associativity
( )
[ ]
.
->
++ --Parentheses (function call) (see Note 1)
Brackets (array subscript)
Member selection via object name
Member selection via pointer
Postfix increment/decrement (see Note 2)left-to-right
++ --
+ -
! ~
(type)
*
&
sizeofPrefix increment/decrement
Unary plus/minus
Logical negation/bitwise complement
Cast (convert value to temporary value of type)
Dereference
Address (of operand)
Determine size in bytes on this implementationright-to-left * / % Multiplication/division/modulus left-to-right + - Addition/subtraction left-to-right << >> Bitwise shift left, Bitwise shift right left-to-right < <=
> >=Relational less than/less than or equal to
Relational greater than/greater than or equal toleft-to-right == != Relational is equal to/is not equal to left-to-right & Bitwise AND left-to-right ^ Bitwise exclusive OR left-to-right | Bitwise inclusive OR left-to-right && Logical AND left-to-right | | Logical OR left-to-right ? : Ternary conditional right-to-left =
+= -=
*= /=
%= &=
^= |=
<<= >>=Assignment
Addition/subtraction assignment
Multiplication/division assignment
Modulus/bitwise AND assignment
Bitwise exclusive/inclusive OR assignment
Bitwise shift left/right assignmentright-to-left ,
Comma (separate expressions) left-to-right - Note 1:
- Parentheses are also used to group sub-expressions to force a different precedence; such parenthetical expressions can be nested and are evaluated from inner to outer.
- Note 2:
- Postfix increment/decrement have high precedence, but the actual increment or decrement of the operand is delayed (to be accomplished sometime before the statement completes execution). So in the statement y = x * z++; the current value of z is used to evaluate the expression (i.e., z++ evaluates to z) and z only incremented after all else is done. See postinc.c for another example.
[面試題]C符號的優先順序的更多相关文章
- 一個新的面試題目,leetcode上面可以找到shortest palindrome
記錄一下新的面試題目,其實題目是舊的,只是我才見到.以前研究過,只不過以前的解法不容易理解,現在有了新的遞歸解法.記錄一下. public String shortestPalindrome(Stri ...
- MOSFET 符號解說
符號 上面這個是 空乏型 的 MOSFET 符號 (有做過修改), 一個是 P channel, 一個是 N channel, 空乏型本身就有通道,所以中間是沒有斷掉的直線, P 代表 + , 有外放 ...
- PMP全真模拟题真题試題含答案解析 2019年下半年PMP考試适用 PMP中文文对照试题 【香港台灣地區PMP考試也可用】
PMP全真模拟题真题试题 含答案解析 2019年下半年PMP考试适用 PMP中文文对照试题 [香港台灣地區PMP考試也可用]PMP全真模擬題真題試題 含答案解析 2019年下半年PMP考試适用 PMP ...
- 最新一道面試題目,input: int[1,1,2,2,2,3,3,3],output [3,2,1],要求按照數字出現的次數從多到少排列元素。
面試當時沒有及時答出來,感覺當時在面試官的提示下跑偏了.想用兩個數組來mapping key和value然後對等排序,但是因為面試官讓用Array.sort而沒想好有什麼好辦法,結果可想而知.但是題目 ...
- .net常見面試題(四)
1. .Net.C#.VisualStudio之间的关系是什么? .Net一般指的是.Net Framework,提供了基础的.Net类,这些类可以被任何一种.Net编程语言调用,.Net Frame ...
- .net常見面試題(二)
一.选择题 1. 下面叙述正确的是___C___. A.算法的执行效率与数据的存储结构无关 B.算法的空间复杂度是指算法程序中指令(或语句)的条数 C.算法的有穷性是指算法必须能在执行有限个步骤之后终 ...
- .net常見面試題(一)
2 .列举ASP.NET 页面之间传递值的几种方式. 答. 1).使用QueryString, 如....?id=1; response. Redirect().... ...
- .Net面試題
初级.NET开发人员 - 任何使用.NET的人都应知道的 1. 描述线程与进程的区别? 进程是系统所有资源分配时候的一个基本单位,拥有一个完整的虚拟空间地址,并不依赖线程而独立存在.进程可以定义程序的 ...
- .net常見面試題(三)
1, 请你说说.NET中类和结构的区别? 答:结构和类具有大体的语法,但是结构受到的限制比类要多.结构不能申明有默认的构造函数,为结构的副本是又编译器创建和销毁的,所以不需要默认的构造函数和析构函数. ...
随机推荐
- 消息中间件之 RocketMQ
参考文档: http://jm.taobao.org/2017/01/12/rocketmq-quick-start-in-10-minutes/ http://rocketmq.apache.org ...
- IDEA创建SpringBoot,并实现、运行简单实例
1.打开IDEA,点击 +Create New Project. 开始创建一个新项目. 2.在左侧菜单找到并点击 Spring Initializr,点击next.注意,这里idea默认使用https ...
- Excel: assign label to scatter chart using specific cell values
ref: https://www.get-digital-help.com/custom-data-labels-in-x-y-scatter-chart/ Improve your X Y Scat ...
- POJ 2778 DNA Sequence ( AC自动机、Trie图、矩阵快速幂、DP )
题意 : 给出一些病毒串,问你由ATGC构成的长度为 n 且不包含这些病毒串的个数有多少个 分析 : 这题搞了我真特么久啊,首先你需要知道的前置技能包括 AC自动机.构建Trie图.矩阵快速幂,其中矩 ...
- 【bzoj3998】[TJOI2015]弦论
题目描述: 对于一个给定长度为N的字符串,求它的第K小子串是什么. 样例输入: aabc 0 3 样例输出: aab 题解: 构造后缀自动机,然后在后缀自动机上跑dfs 代码: #include &l ...
- django-rest-swagger 使用【转】
转自:https://www.cnblogs.com/delav/p/10242017.html Swagger是一个API开发者的工具框架,用于生成.描述.调用和可视化RESTful风格的Web服务 ...
- es之java插入优化(批量插入)
插入文档操作的一种优化,因为每次插入单条文档,都会向es中发送请求.然后es执行在返回结果: 如果有大批量的文档数据需要插入,这个时候单挑插入操作显然是不合理的: 之前学习的命令行批量执行方式: PO ...
- GitHub最著名的20个Python机器学习项目
GitHub最著名的20个Python机器学习项目 我们分析了GitHub上的前20名Python机器学习项目,发现scikit-Learn,PyLearn2和NuPic是贡献最积极的项目.让我们一起 ...
- c# 用DotNetZip来解压/压缩文件
//https://archive.codeplex.com/?p=dotnetzip //最新在Nuget 下载DotNetZip using Ionic.Zip; private void but ...
- 无法绕开的cut, awk, sed命令
linux命令的选项和选项后面的值的方式: 如果用 短选项, 选项值就放在短选项的后面, 如果用长选项, 值就用等于的方式. 最重要的是, 短选项后面的值, 跟短选项之间, 可以用空格, 也可以紧接着 ...