上海交通大学:《C程序与算法设计》课程教学资源(讲稿)Lecture 05 C语言语句
if语句 对于==(equality)和=(assignment)的混淆与误用是最常 见的C编程错误 if (i==0).../tests whether i is equal to 0 if (i=0).../assigns o to i,then tests whether the result is nonzero if (0 <i&&i<n).../test whether 0<= i<n (i is inside a range) if (i<0 i>=n).../test the opposite condition (i is outside the range) 5/68. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . if 语句 对于 == (equality) 和 = (assignment) 的混淆与误用是最常 见的 C 编程错误 if (i == 0) ... / / tests whether i i s equal to 0 if (i = 0) ... / / assigns 0 to i , then tests whether the re sul t i s nonzero if (0 <= i && i < n) ... / / test whether 0 <= i < n ( i i s inside a range) if (i < 0 || i >= n) ... / / test the opposite condition ( i i s outside the range) 5 / 68
<<向上翻页向下翻页>>