&& A&&B 同真为真 A\B任意一个为假 即为假 短路特性:如果A=假 则B表达式则不会运行
#include <stdio.h> #include <stdlib.h> void test() {
int n = 10; printf("n的值为%d\n", n); (3 < 2) && (n = 100); printf("n的值为%d\n", n); } int main(int argc, char *argv[]) {
test(); system("pause"); return 0; }
讯享网
输出结果
n的值为10
n的值为10
|| A||B 同假为真 A\B任意一个为真 即为真 短路特性:如果A=真 则B表达式则不会运行
讯享网#include <stdio.h> #include <stdlib.h> void test() {
int n = 10; printf("n的值为%d\n", n); (3 > 2) || (n = 100); printf("n的值为%d\n", n); } int main(int argc, char *argv[]) {
test(); system("pause"); return 0; }
n的值为10
n的值为10

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请联系我们,一经查实,本站将立刻删除。
如需转载请保留出处:https://51itzy.com/kjqy/16206.html