[面試題]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中类和结构的区别? 答:结构和类具有大体的语法,但是结构受到的限制比类要多.结构不能申明有默认的构造函数,为结构的副本是又编译器创建和销毁的,所以不需要默认的构造函数和析构函数. ...
随机推荐
- 半小时写完替罪羊重构点分树做动态动态点分治之紫荆花之恋的wyy贴心指导
刷题训练 初学者 有一定语言基础,但是不了解算法竞赛,水平在联赛一等奖以下的. 参考书:<算法竞赛入门经典--刘汝佳>,<算法竞赛入门经典训练指南--刘汝佳> 题库:洛谷(历年 ...
- 【UOJ#207】共价大爷游长沙
题目链接 题目描述 火车司机出秦川,跳蚤国王下江南,共价大爷游长沙.每个周末,勤劳的共价大爷都会开车游历长沙市. 长沙市的交通线路可以抽象成为一个 \(n\) 个点 \(n−1\) 条边的无向图,点编 ...
- 【leetcode】313. Super Ugly Number
题目如下: 解题思路:总结一下这么几点,一出一进,优先级队列排序,保证每次输出的都是当前的最小值.解法大致如图: 代码如下: #include<map> #include<queue ...
- 【leetcode】540. Single Element in a Sorted Array
题目如下: 解题思路:题目要求时间复杂度是O(logN),可以尝试使用二分查找法.首先数组是有序的,而且仅有一个元素出现一次,其余均为两次.我们可以先找到数组最中间的元素,记为mid.如果mid和mi ...
- LeetCode--114--二叉树展开为链表(python)
给定一个二叉树,原地将它展开为链表. 例如,给定二叉树 1 / \ 2 5 / \ \ 3 4 6将其展开为: 1 \ 2 \ 3 \ 4 \ ...
- Linux学习-NFS服务
一.NFS服务相关介绍 1.NFS简介 NFS (Network File System) 网络文件系统,基于内核的文件系统.Sun公司开发,通过使用NFS,用户和程序可以像访问本地文件一样访问远端系 ...
- Linux学习-FTP服务
一.FTP相关介绍 1.文本传输协议FTP FTP (File Transfer Protocol) 文件传输协议,是因特网中使用最广泛的文件传输协议: 基于C/S结构的双通道协议(数据和命令连接) ...
- 3D Computer Grapihcs Using OpenGL - 03 OpenGL Buffer Data
本节绘制一个三角形,并讲解Buffer Object-缓冲对象 OpenGL的窗口坐标 屏幕中心为坐标原点,横向朝右为x正方向,纵向朝上为y正方向,最大值最小值分别为1,-1. Buffer Obje ...
- AC自动机再加强版
AC自动机 拓扑排序优化,注意拓扑排序前要把所有入度为零的点都加进去 #include<bits/stdc++.h> using namespace std; #define maxn 1 ...
- node.js安装和配置(windows系统)
node.js安装和配置(windows系统) node javasript vscode node是javascript的管理工具,所以开发javasript项目都要下载安装和配置node. 传送 ...