C/C++逻辑运算的验证原则

来源:互联网 发布:mac画结构图工具 编辑:程序博客网 时间:2024/05/19 14:17

基本原则为:从左向右,当前逻辑表达式不满足立刻停止后续验证

code

// test.cpp : 定义控制台应用程序的入口点。//#include "stdafx.h"#include <stdlib.h>int main(void){int m=0;int n=0;if(m==1 && ++n==1){printf("It is OK!\n");}printf("The first n=%d\n",n);if(++n==1 && m==1){printf("It is in!\n");}printf("The second n=%d\n",n);system("pause");return 0;}


0 1
原创粉丝点击